日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SwipeRefreshLayout官方推荐下拉刷新

發布時間:2023/12/2 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SwipeRefreshLayout官方推荐下拉刷新 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
SwipeRefreshLayout
public class SwipeRefreshLayout?
extends ViewGroup implements NestedScrollingParent, NestedScrollingChild


java.lang.Object
? ?? android.view.View
? ? ? android.view.ViewGroup

? ? ? android.support.v4.widget.SwipeRefreshLayout

API doc:http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html

主要方法

  • setOnRefreshListener(OnRefreshListener): 為布局添加一個Listener

  • setRefreshing(boolean): 顯示或隱藏刷新進度條

  • isRefreshing(): 檢查是否處于刷新狀態

  • setColorScheme(): 設置進度條的顏色主題,最多能設置四種

布局: 在最外層加上SwipeRefreshLayout,他的child是可滾動的view即可,如ScrollView或者ListView

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:id="@+id/swipe_refresh_layout"><ScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:id="@+id/refresh"android:layout_width="wrap_content"android:layout_height="wrap_content" android:layout_gravity="center"android:textSize="24sp"android:text="下拉刷新" /></ScrollView> </android.support.v4.widget.SwipeRefreshLayout> 在代碼中使用:

public class MainActivity extends ActionBarActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_main);final TextView mTextView = (TextView)findViewById(R.id.refresh);final SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipe_refresh_layout);mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_blue_light, android.R.color.holo_green_light, android.R.color.holo_orange_light);mSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener(){@Overridepublic void onRefresh() {mTextView.setText("正在刷新");// TODO Auto-generated method stub//boolean android.os.Handler.postDelayed(Runnable r, long delayMillis)new Handler().postDelayed(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubmTextView.setText("刷新完成");mSwipeRefreshLayout.setRefreshing(false);}}, 5000);}});}}

Tanks to:stormzhang:http://stormzhang.com/android/2014/03/29/android-swiperefreshlayout/

http://www.cnblogs.com/JinyaoLi/p/3852424.html

總結

以上是生活随笔為你收集整理的SwipeRefreshLayout官方推荐下拉刷新的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。