亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

廢話(huà)不多說(shuō),效果圖奉上:

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); 
 } 
} 


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

相關(guān)文章

最新評(píng)論