前言: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的更多相关文章

  1. Android开源框架ViewPagerIndicator的基本使用

    转载本博客请注明出处:点击打开链接    http://blog.csdn.net/qq_32059827/article/details/52495647 很多新闻资讯类的app都有一些共性,那就是 ...

  2. Android百大框架排行榜

    Android百大框架排行榜 15类Android通用流行框架 - 流风,飘然的风 - 博客园https://www.cnblogs.com/zdz8207/p/android-opensource- ...

  3. 2017年Android百大框架排行榜

    框架:提供一定能力的小段程序 >随意转载,标注作者"金诚"即可 >本文已授权微信公众号:鸿洋(hongyangAndroid)原创首发. >本文已经开源到Gith ...

  4. android 优秀框架整理

    程序员界有个神奇的网站,那就是github,这个网站集合了一大批优秀的开源框架,极大地节省了开发者开发的时间,在这里我进行了一下整理,这样可以使我们在使用到时快速的查找到,希望对大家有所帮助! 1. ...

  5. 2017年Android百大框架排行榜(转)

    一.榜单介绍 排行榜包括四大类: 单一框架:仅提供路由.网络层.UI层.通信层或其他单一功能的框架 混合开发框架:提供开发hybrid app.h5与webview结合能力.web app能力的框架 ...

  6. Android开源框架ViewPageIndicator和ViewPager实现Tab导航

    前言: 关于使用ViewPageIndicator和ViewPager实现Tab导航,在开发社区里已经有一堆的博客对其进行了介绍,假设我还在这里写怎样去实现.那简直就是老生常谈,毫无新奇感,并且.我也 ...

  7. Android 开源框架Universal-Image-Loader学习

    Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用 Android 开源框架Universal-Image-Loader完全解析(二)--- 图片 ...

  8. Android 数据库框架OrmLite的使用(一)

    在这里记录下最基本的用法,官网上可了解相关的介绍. 1.下载OrmLite jar 在下载android的:ormlite-android-4.48.jar和ormlite-core-4.48.jar ...

  9. Android 开源框架Universal-Image-Loader完全解析(三)---源代码解读

    转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/39057201),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...

  10. Android 开源框架Universal-Image-Loader完全解析(二)--- 图片缓存策略详解

    转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/26810303),请尊重他人的辛勤劳动成果,谢谢! 本篇文章 ...

随机推荐

  1. LibreOffice创建数据透视表

    LibreOffice创建数据透视表 LibreOffice: 选中数据,Data->Pivot Table->Create,拖拽行.列到Row和column,Data Filed要点击O ...

  2. shell脚本编写注意事项

    shell中赋值变量时不能有空格 之前写python写习惯了 test = ‘free -m’ 在shell中不能有空格 test='free -m' 而且使用管道符之前要留空格 test='free ...

  3. OS中处理机调度模型和调度算法

    OS中处理机调度模型和调度算法 调度层次 1.1. 高级调度(长程调度,作业调度) 功能:依据某种算法.把在外存队列上处于后备队列的那些作业调入内存.以作业为操做对象. 作业:比程序更为广泛的概念,不 ...

  4. POJ 2386 Lake Counting 搜索题解

    简单的深度搜索就能够了,看见有人说什么使用并查集,那简直是大算法小用了. 由于能够深搜而不用回溯.故此效率就是O(N*M)了. 技巧就是添加一个标志P,每次搜索到池塘,即有W字母,那么就觉得搜索到一个 ...

  5. HDFS 中向 DataNode 写入数据失败了怎么办

    https://blog.csdn.net/HeatDeath/article/details/79012258 http://wenda.chinahadoop.cn/question/3323 h ...

  6. 【招聘App】—— React/Nodejs/MongoDB全栈项目:个人中心&退出登录

    前言:最近在学习Redux+react+Router+Nodejs全栈开发高级课程,这里对实践过程作个记录,方便自己和大家翻阅.最终成果github地址:https://github.com/66We ...

  7. Windows正在使用无法停止通用卷怎么办

    最后解决方案1: 1.双击任务栏上的安全删除硬件图标 2.按下Ctrl + Alt + Del 组合键调出"任务管理器": 3.结束其中的explorer.exe进程,此时桌面上的 ...

  8. Pinterest架构:两年内月PV从零到百亿

    Pinterest正经历了指数级曲线般的增长,每隔一个半月就翻番.在这两年里,Pinterest,从 每月PV量0增长到100亿,从两名c创始人和一个工程师成长为四十个工程师,从一台MySQL 服务器 ...

  9. Android基于UDP的局域网聊天通信

    代码地址如下:http://www.demodashi.com/demo/12057.html 记得把这几点描述好咯:代码实现过程 + 项目文件结构截图 + 演示效果 1. 开发环境 1.1 开发工具 ...

  10. 9、Linux驱动的杂项设备

    杂项设备,是字符设备中的特殊,它的主设备号,是 10,不同的杂项设备,通过次设备号进行区分. 1.注册与注销 int misc_register(struct miscdevice * misc) 完 ...