前言: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. django+celery+redis实现运行定时任务

    0.目的 在开发项目中,经常有一些操作时间比较长(生产环境中超过了nginx的timeout时间),或者是间隔一段时间就要执行的任务. 在这种情况下,使用celery就是一个很好的选择.   cele ...

  2. leetcode练习之No.1------ 两数之和Two Sum

    github地址:git@github.com:ZQCard/leetcode.git 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数. 你可以假设每个输入只对应一种答案,且同样的元素不能 ...

  3. Python 的 LEGB 规则(转载)

    转载:https://mp.weixin.qq.com/s?timestamp=1498528588&src=3&ver=1&signature=DfFeOFPXy44ObCM ...

  4. 关于 iOS 证书,你必须了解的知识

    收录待用,修改转载已取得腾讯云授权 最新腾讯云技术公开课直播,提问腾讯W3C代表,如何从小白成为技术专家?点击了解活动详情. 作者 |陈泽滨 编辑 | 顾乡 从事iOS开发几年,越来越发现,我们的开发 ...

  5. How to backup a remote PostgreSQL db and restore it locally?

    pg_dump and pg_restore 来备份和恢复数据库中的数据. 原文:  https://ksearch.wordpress.com/2012/09/28/how-to-backup-a- ...

  6. 使RESTful Web服务更加实用的10个建议

    提示:随着RESTful Web services的流行程度不断地上升,开发人员需要知道如何避免开发中的陷阱以及让开发出来的Web service达到自己能做到的最好程度. 过去的几年里,我们看到RE ...

  7. ant-design table 分页(tableProps)

    1.布局 <Table dataSource={this.state.tableDetailList} scroll={{ y: '200px' }} style={{tableLayout: ...

  8. oracle获取时间毫秒数

    select (sysdate-to_date('1970-01-01','yyyy-mm-dd')-8/24)*24*60*60*1000-1* 60 * 60 * 1000  millisecon ...

  9. js ctrl+v实现图片粘贴

    <script> // demo 程序将粘贴事件绑定到 document 上 document.addEventListener("paste", function ( ...

  10. 转 iOS:NSAttributedString

    NSAttributedString: http://blog.csdn.net/kmyhy/article/details/8895638 CTFramesetterSuggestFrameSize ...