最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android SwipeRefreshLayout仿抖音app靜態(tài)刷新

 更新時間:2018年03月08日 10:22:47   作者:zpf_  
這篇文章主要為大家詳細(xì)介紹了Android SwipeRefreshLayout仿抖音app靜態(tài)刷新,具有一定的參考價值,感興趣的小伙伴們可以參考一下

SwipeRefreshLayout的功能就是可以讓我們的界面在不動的情況下,下拉直接刷新

廢話不多說,效果圖奉上:

activity_listview布局文件

<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/sr1" 
    android:layout_width="match_parent" 
   android:layout_height="match_parent"> 
    <ListView 
     android:id="@+id/lv" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 
   </android.support.v4.widget.SwipeRefreshLayout> 

Activity代碼(ListViewActivity)

public class ListViewActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener { 
 private SwipeRefreshLayout swipeRefreshLayout; 
 private ListView listView; 
 private List<String> list; 
 private ArrayAdapter adapter; 
 
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.activity_list_view); 
  swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.sr1); 
  swipeRefreshLayout.setOnRefreshListener(this); 
  list = new ArrayList<>(); 
  list.add("ssss"); 
  listView = (ListView) findViewById(R.id.lv); 
  adapter = new ArrayAdapter(this 
    , android.R.layout.simple_list_item_1 
    , android.R.id.text1 
    , list); 
  listView.setAdapter(adapter); 
 } 
 
 @Override 
 public void onRefresh() { 
  new Handler().postDelayed(new Runnable() { 
   @Override 
   public void run() { 
    swipeRefreshLayout.setRefreshing(false); 
    adapter.clear(); 
    list.add("1111"); 
    adapter.notifyDataSetChanged(); 
   } 
  }, 1000); 
 } 
} 


以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

三明市| 杂多县| 拜城县| 沛县| 济南市| 鹤山市| 永泰县| 潞城市| 阳曲县| 南召县| 新龙县| 巴塘县| 顺平县| 团风县| 西乌珠穆沁旗| 娱乐| 遂宁市| 宜都市| 涡阳县| 弥渡县| 崇阳县| 北川| 临湘市| 诸暨市| 鱼台县| 阳春市| 伊川县| 甘南县| 西宁市| 柳河县| 常州市| 四子王旗| 牟定县| 洛川县| 巴里| 荆门市| 鸡泽县| 大洼县| 连云港市| 天全县| 璧山县|