ViewPagerIndicator使用流程记录

来源:互联网 发布:人工智能的好处英文 编辑:程序博客网 时间:2024/05/21 19:33

ViewPagerIndicator使用流程:


1.引入库文件;


2.在需要用到ViewPagerIndicator的布局文件中增加

<com.viewpagerindicator.TabPageIndicator 控件;


3.在Pager中拿到2中的控件mIndicator;


4.mIndicator.setViewPager()将ViewPager和指示器绑定在一起 必须在ViewPager设置完数据之后再绑定;


5.在PagerAdapter 中重写 public CharSequence getPageTitle(int position) {} 重新设置Tab标题;


6.根据需要,修改ViewPagerIndicator源码中的相关颜色;


7.当和侧边栏一起使用时候,要想侧边栏不相应ViewPagerIndicator 的向右滑动:
在TabPageIndicator 源码中重写
<span style="font-size:24px;">@Override //事件分发流程!!!public boolean dispatchTouchEvent(MotionEvent ev) {//请求所有父控件不要拦截事件getParent().requestDisallowInterceptTouchEvent(true);return super.dispatchTouchEvent(ev);}</span>


8.当Viewpager和ViewPagerIndicator都存在的情况下,要将原本设置给Viewpager的监听转移到ViewPagerIndicator上面.(具体原因我不清楚,但是我觉得应该是ViewPagerIndicator比较任性)

0 0
原创粉丝点击