SwipeRefreshLayout 的基本使用

Myth丶恋晨 2022-09-25 06:18 320阅读 0赞
  1. SwipeRefreshLayout 可以实现下拉刷新的动作效果,加载内容的时候是很有必要使用的
  2. 1.在布局文件
  3. <android.support.v4.widget.SwipeRefreshLayout
  4. android:id="@+id/sr_layout"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent">
  7. //中间放入其他控件
  8. </android.support.v4.widget.SwipeRefreshLayout>
  9. 2. private SwipeRefreshLayout sr_layout;
  10. sr_layout = (SwipeRefreshLayout) findViewById(R.id.sr_layout);
  11. sr_layout.setOnRefreshListener(this);//需在主activity,implements SwipeRefreshLayout.OnRefreshListener
  12. sr_layout.setColorSchemeColors(R.color.blue);//设置加载时的颜色显示
  13. @Override
  14. public void onRefresh() {
  15. //下拉加载时的具体实现功能
  16. }

发表评论

表情:
评论列表 (有 0 条评论,320人围观)

还没有评论,来说两句吧...

相关阅读

    相关 SwipeRefreshLayout

    也许之前下拉刷新你可能会用到一些第三方开源库,如PullToRefresh, ActionBar-PullToRefresh、XlistView等 但现在已经有官方的组件了-