Android-ViewPagerIndicator框架使用——IconPageIndicator
前言:IconPageIndicator是将自定义的图片作为指示图标的,这里的图片使用xml实现的。
1.自己定义图片:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/perm_group_calendar_selected" />
<item android:drawable="@drawable/perm_group_calendar_normal" />
</selector>
2.定义布局文件simple_icons:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > <android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" /> <com.viewpagerindicator.IconPageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
3:代码中使用布局:
setContentView(R.layout.simple_icons);
//这个adapter需要实现IconPagerAdapter中的两个方法
mAdapter = new TestFragmentAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(mAdapter); mIndicator = (IconPageIndicator) findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
其中的mAdapter是实现了IconPagerAdapter中的两个方法:
public interface IconPagerAdapter {
/**
* 获得图片作为指示标识
*/
int getIconResId(int index);
/**
* 获得pager个数
*/
int getCount();
}
具体使用如下:
class TestFragmentAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
protected static final int[] ICONS = new int[] {
R.drawable.perm_group_calendar,
R.drawable.perm_group_camera,
R.drawable.perm_group_device_alarms,
R.drawable.perm_group_location
};
.......
@Override
public int getIconResId(int index) {
return ICONS[index % ICONS.length];
}
}
源码以及Demo下载地址:http://download.csdn.net/detail/as294985925/6796117
Android-ViewPagerIndicator框架使用——IconPageIndicator的更多相关文章
- Android开源框架ViewPagerIndicator的基本使用
转载本博客请注明出处:点击打开链接 http://blog.csdn.net/qq_32059827/article/details/52495647 很多新闻资讯类的app都有一些共性,那就是 ...
- Android百大框架排行榜
Android百大框架排行榜 15类Android通用流行框架 - 流风,飘然的风 - 博客园https://www.cnblogs.com/zdz8207/p/android-opensource- ...
- 2017年Android百大框架排行榜
框架:提供一定能力的小段程序 >随意转载,标注作者"金诚"即可 >本文已授权微信公众号:鸿洋(hongyangAndroid)原创首发. >本文已经开源到Gith ...
- android 优秀框架整理
程序员界有个神奇的网站,那就是github,这个网站集合了一大批优秀的开源框架,极大地节省了开发者开发的时间,在这里我进行了一下整理,这样可以使我们在使用到时快速的查找到,希望对大家有所帮助! 1. ...
- 2017年Android百大框架排行榜(转)
一.榜单介绍 排行榜包括四大类: 单一框架:仅提供路由.网络层.UI层.通信层或其他单一功能的框架 混合开发框架:提供开发hybrid app.h5与webview结合能力.web app能力的框架 ...
- Android开源框架ViewPageIndicator和ViewPager实现Tab导航
前言: 关于使用ViewPageIndicator和ViewPager实现Tab导航,在开发社区里已经有一堆的博客对其进行了介绍,假设我还在这里写怎样去实现.那简直就是老生常谈,毫无新奇感,并且.我也 ...
- Android 开源框架Universal-Image-Loader学习
Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用 Android 开源框架Universal-Image-Loader完全解析(二)--- 图片 ...
- Android 数据库框架OrmLite的使用(一)
在这里记录下最基本的用法,官网上可了解相关的介绍. 1.下载OrmLite jar 在下载android的:ormlite-android-4.48.jar和ormlite-core-4.48.jar ...
- Android 开源框架Universal-Image-Loader完全解析(三)---源代码解读
转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/39057201),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...
- Android 开源框架Universal-Image-Loader完全解析(二)--- 图片缓存策略详解
转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/26810303),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...
随机推荐
- linux下目录大小为什么是4K?一个目录下最多有个多少个子目录?最多有多少个文件?ls -l显示的内容中total到底是什么?
子目录数太多,会影响搜索性能. 在同一个路径下,一级子目录的个数限制为31998,如果你的应用生成的目录可能会超过这个数,那要注意进行目录分级.例如,如果目录名为数字的话,可以将数字除以10000后的 ...
- wireshark----教你怎样抓包
wireshark----教你怎样抓包 wireshark是一款强大的抓包工具,走过路过一定不要错过就是了,当你学习TCP/IP协议的时候,学习使用wireshark抓包正是理论联系实际最好的方法,先 ...
- unity render pipeline
post process v2 GUI temp8->TaregtPool0->temp8 tem8 temp8->backbu ...
- 深度增强学习--Deep Q Network
从这里开始换个游戏演示,cartpole游戏 Deep Q Network 实例代码 import sys import gym import pylab import random import n ...
- Java笔记7:最简单的网络请求Demo
一.服务器端 1 新建一个工程,建立一个名为MyRequest的工程. 2 FileàProject StructureàModulesà点击最右侧的“+”àLibraryàJava 找到Tomcat ...
- Socket网络通讯开发总结之:Java 与 C进行Socket通讯(转)
先交待一下业务应用背景:服务端:移动交费系统:基于C语言的Unix系统客户端:增值服务系统:基于Java的软件系统通迅协议:采用TCP/IP协议,使用TCP以异步方式接入数据传输:基于Socket流的 ...
- 用C++实现Huffman文件编码和解码(2 总结)
这个是代码是昨天写完的,一开始的时候还出了点小bug,这个bug在晚上去吃饭的路上想明白的,回来更改之后运行立刻完成最后一步,大获成功. 简单说下huffman编码和文件压缩主要的技术. Huffma ...
- 两列布局(浮动、定位、flex)和三列布局(圣杯、双飞翼、flex)
demo 各种布局演示 https://jsfiddle.net/mayufo/qp890peq/1/ 两栏布局 浮动 <div class="box1"> <d ...
- FBXImport
using UnityEditor; public class MyEditor : AssetPostprocessor{ public void OnPreprocessModel() { Mod ...
- vue 预渲染 prerender-spa-plugin
1.预渲染说明 https://ssr.vuejs.org/zh/#为什么使用服务器端渲染-ssr-? 如果你调研服务器端渲染(SSR)只是用来改善少数营销页面(例如 /, /about, /cont ...