- 13
- 0
- 约3.37万字
- 约 43页
- 2018-06-28 发布于湖北
- 举报
—————————————————————————————PAGE \* MERGEFORMAT1新闻客户端讲师:杨光福微博:/321chinavideo Day41_自定义ListView(加载更多)-4201_添加角布局 1_初始化和隐藏代码在RefreshListView构造方法中调用 /** * 添加角布局 * @param context */ private void initFooterView(Context context) { View footerView = View.inflate(context, R.layout.refresh_listview_footer, null); //隐藏代码 footerView.measure(0, 0); int footerViewHeight = footerView.getMeasuredHeight(); footerView.setPadding(0, -footerViewHeight, 0, 0); this.addFooterView(footerView); }2_布局文件refresh_listview_footer.xml ?xml version=1.0 encoding=utf-8?LinearLayout xmlns:android=/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 public void onScrollStateChanged(AbsListView view, int scrollState) { //当停止滚动时或者惯性滚动时,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 public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } /** * 自定义刷新接口 * */ public interface OnRefreshListener{ /** * 当下拉刷新的时候回调这儿方法 */ public void onPullDo
您可能关注的文档
最近下载
- 砀山经济开发区市政道路工程(1-3标段)砀山经济开发区市政道路工程(1-3标段).doc VIP
- 2025年企业云会计在医药行业的应用与合规性报告.docx VIP
- 国网风区分布图(2024年版)上册.pdf VIP
- Fujifilm富士 相机 GFX100RF 用户手册.pdf
- 中国教育史:战国时期的教育PPT教学课件.pptx VIP
- 风管比摩阻、局部阻力速算表.xlsx VIP
- [12]发明专利申请公开说明书.PDF VIP
- 法国规范NFP94-051-阿太堡极限的测定要点解析.pdf VIP
- 2025至未来5年中国黄须(蓿)菜市场数据分析及竞争策略研究报告.docx
- 2023年甘肃兰州市中考一诊语文试卷(含答案).pdf
原创力文档

文档评论(0)