预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共43页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

————————————————————————————— PAGE\*MERGEFORMAT43 新闻客户端 讲师:杨光福 微博:http://weibo.com/321chinavideo Day4 1_自定义ListView(加载更多)-42 01_添加角布局 1_初始化和隐藏代码 在RefreshListView构造方法中调用 /** *添加角布局 *@paramcontext */ privatevoidinitFooterView(Contextcontext){ ViewfooterView=View.inflate(context,R.layout.refresh_listview_footer,null); //隐藏代码 footerView.measure(0,0); intfooterViewHeight=footerView.getMeasuredHeight(); footerView.setPadding(0,-footerViewHeight,0,0); this.addFooterView(footerView); } 2_布局文件refresh_listview_footer.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <ProgressBar android:layout_margin="5dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminateDrawable="@drawable/custom_progressbar"/> <TextView android:layout_marginLeft="10dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="加载更多中..." android:textColor="#ff0000" android:textSize="25sp"/> </LinearLayout> 02_拖动到底部的时候显示角 1_拖动到底部显示加载更多布局 /** *当滚动状态改变的时候触发此方法 * */ @Override publicvoidonScrollStateChanged(AbsListViewview,intscrollState){ //当停止滚动时或者惯性滚动时,ListView的最后一个显示的条目:getCount()-1 if(scrollState==SCROLL_STATE_IDLE||scrollState==SCROLL_STATE_FLING){ if(getLastVisiblePosition()==(getCount()-1)){ //滑动到最后一个可以看到的Item System.out.println("滑动到最后一个可以看到的Item"); isLoadingMore=true; //把底部加载显示 footerView.setPadding(0,0,0,0); setSelection(getCount()); //调用 if(mOnRefreshListener!=null){ mOnRefreshListener.onLoadingMore(); } } } } @Override publicvoidonScroll(AbsListViewview,intfirstVisibleItem, intvisibleItemCount,inttotalItemCount){ } /** *自定义刷新接口 * */ publicinterfaceOnRefreshListener{ /** *当下拉刷新的时候回调这儿方法 */ publicvoidonPullDow