<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 1. 前言 `SwipeRefreshLayout`就是用于實現下拉刷新功能的核心類,我們把想要實現下拉刷新功能的控件放置到`SwipeRefreshLayout`中,就可以迅速讓這個控件支持下拉刷新。 # 2. 使用 需要添加一下依賴: ~~~ implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' ~~~ 然后在`xml`文件中將要下拉刷新的包裹起來: ~~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <!--引入下拉刷新控件--> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/swiperefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- 將內容包裹起來 --> <TextView android:layout_width="wrap_content" android:layout_height="?attr/actionBarSize" android:text="測試下拉刷新" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </LinearLayout> ~~~ 然后,我們需要在代碼中處理具體的刷新邏輯: ~~~ class TestActivity : AppCompatActivity() { // 找到下拉刷新控件 val swiperefreshLayout by lazy { findViewById<SwipeRefreshLayout>(R.id.swiperefreshLayout) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_test) // 設置下拉刷新的圓圈的顏色 swiperefreshLayout.setColorSchemeResources(R.color.purple_700) // 模擬數據耗時請求 swiperefreshLayout.setOnRefreshListener { refershData() } } fun refershData(){ // 模擬請求,耗時兩秒結束 thread { Thread.sleep(2000) runOnUiThread { // 設置停止下拉刷新 swiperefreshLayout.isRefreshing = false } } } } ~~~ 結果: ![](https://img.kancloud.cn/86/25/8625cdd98b691b06f34fef0eb653a9e1_303x102.png) 下拉刷新旋轉兩秒消失。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看