[ViewPager、二]ViewPager 小圆点 动态添加

来源:互联网 发布:淘宝达人账号简介内容 编辑:程序博客网 时间:2024/05/18 12:33

做个备注记录:

一、动态添加小圆点:

其中

mData:为数据链表
<pre name="code" class="java">dots_id:为上级节点
<pre name="code" class="java">R.layout.dot_pull_new_item_s:为样式

private void setDots(ArrayList<PullProvinceListBean> mData,int arg0){/** * 加viewPager底部点 * */ dots_id.removeAllViews();for (int i = 0; i < mData.size(); i++) {if(i==arg0){View dot = LayoutInflater.from(getApplicationContext()).inflate(R.layout.dot_pull_new_item_s, dots_id);}else{View dot = LayoutInflater.from(getApplicationContext()).inflate(R.layout.dot_pull_new_item, dots_id);}}}
二、参数arg0

@Overridepublic void onPageSelected(int arg0) {setDots(mData,arg0);}
三、dot_pull_new_item_s

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:orientation="vertical" >    <ImageView        android:id="@+id/dot_pn_item_id"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:background="@drawable/dot_select"        /></LinearLayout>




0 0
原创粉丝点击