国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

android組件SwipeRefreshLayout下拉小球式刷新效果

2019-10-23 19:46:39
字體:
供稿:網(wǎng)友

swiperefreshlayout實現(xiàn)下拉小球式的刷新,供大家參考,具體內(nèi)容如下

布局文件:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">  <android.support.v4.widget.SwipeRefreshLayout    android:id="@+id/swipeRefreshLayout"    android:layout_width="wrap_content"    android:layout_height="wrap_content"  >   <ListView     android:id="@+id/listView"     android:layout_width="match_parent"     android:layout_height="wrap_content">   </ListView>  </android.support.v4.widget.SwipeRefreshLayout></RelativeLayout>

MainActivity:

public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener{private static final int REFRESH_STATUS =0;private ListView myListView;private SwipeRefreshLayout mySwipeRefreshLayout;private ArrayAdapter<String> listAdapter;private List<String> listIDE = new ArrayList<String>(Arrays.asList("Visual Studio", "Android Studio", "Eclipse", "Xcode"));private Handler refreshHandler = new Handler(){  public void handleMessage(android.os.Message msg)  {    switch (msg.what)    {      case REFRESH_STATUS:        listIDE.removeAll(listIDE);        listIDE.addAll(Arrays.asList("C#", "Java", "C++","Object-C"));        listAdapter.notifyDataSetChanged();        mySwipeRefreshLayout.setRefreshing(false);        break;    }  };};protected void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.activity_main);  myListView = (ListView) findViewById(R.id.listView);  mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);  mySwipeRefreshLayout.setOnRefreshListener(this);  mySwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light,      android.R.color.holo_orange_light, android.R.color.holo_red_light);  listAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,listIDE);  myListView.setAdapter(listAdapter);}@Overridepublic void onRefresh() {  refreshHandler.sendEmptyMessageDelayed(REFRESH_STATUS, 1500); }}

效果圖:

android,下拉刷新,SwipeRefreshLayout

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


注:相關(guān)教程知識閱讀請移步到Android開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 新干县| 玛纳斯县| 健康| 平远县| 枝江市| 上饶县| 广州市| 枣强县| 类乌齐县| 松江区| 高青县| 水城县| 兰州市| 榆中县| 北碚区| 宁陵县| 徐汇区| 建瓯市| 乡宁县| 织金县| 图片| 延寿县| 定安县| 紫阳县| 平陆县| 平远县| 米易县| 迭部县| 江川县| 扶余县| 余江县| 韶关市| 泰来县| 城步| 民乐县| 广州市| 武隆县| 通海县| 阳西县| 思茅市| 思茅市|