<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                listview,scrollview,recyclerview等如果碰到更新比較快的數據,沒有下拉刷新就顯得特別呆板了。于是google就推出了swipeRefreshLayout 這個簡單卻又實用的組件(知乎APP就是用的這個哦)。 筆者博文還是主要給新手提供一個簡單的demo學習,效果如下: ![](https://box.kancloud.cn/2016-03-01_56d5568df0ac7.jpg) ?![](https://box.kancloud.cn/2016-03-01_56d5568e14bac.jpg) ?![](https://box.kancloud.cn/2016-03-01_56d5568e2d6f0.jpg) 代碼特別簡單,就不多加描述了。 MainActivity: ~~~ package com.example.swiperefreshlayouttest; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.support.v4.widget.SwipeRefreshLayout; import android.widget.ArrayAdapter; import android.widget.ListView; import java.util.ArrayList; import java.util.List; import java.util.Random; public class MainActivity extends Activity implements SwipeRefreshLayout.OnRefreshListener{ private SwipeRefreshLayout swipeRefreshLayout; private ListView listView; private ArrayAdapter<String> adapter; private List<String> data; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.listView); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); data = new ArrayList<String>(); for (int i = 0; i < 20; i++) { data.add("當前的item為 " + i); } adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, data); listView.setAdapter(adapter); //在刷新等待時,滾動條顏色的變化 swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light); //給swipeRefreshLayout綁定刷新監聽 swipeRefreshLayout.setOnRefreshListener(this); } @Override public void onRefresh() { //設置2.5秒的時間來執行以下事件 new Handler().postDelayed(new Runnable() { public void run() { data.add(0, "刷新后新增的item"); adapter.notifyDataSetChanged(); swipeRefreshLayout.setRefreshing(false); } }, 2500); } } ~~~ activity_main: ~~~ <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipeRefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent" android:footerDividersEnabled="false" /> </android.support.v4.widget.SwipeRefreshLayout> ~~~
                  <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>

                              哎呀哎呀视频在线观看