Android下拉刷新上拉加载简单的实现方法(6)

private void onLoad() {
  mListView.stopRefresh();
  mListView.stopLoadMore();
  mListView.setRefreshTime("鍒氬垰");
 }
 
 @Override
 public void onRefresh() {
  mHandler.postDelayed(new Runnable() {
   @Override
   public void run() {
    start = ++refreshCnt;
    items.clear();
    geneItems();
    // mAdapter.notifyDataSetChanged();
    mAdapter = new ArrayAdapter<String>(XListViewActivity.this, R.layout.list_item, items);
    mListView.setAdapter(mAdapter);
    onLoad();
   }
  }, 2000);
 }

@Override
 public void onLoadMore() {
  mHandler.postDelayed(new Runnable() {
   @Override
   public void run() {
    geneItems();
    mAdapter.notifyDataSetChanged();
    onLoad();
   }
  }, 2000);
 }

}

layout文件源码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" android:background="#f0f0f0">

<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

<me.maxwin.view.XListView
        android:id="@+id/xListView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:cacheColorHint="#00000000">
    </me.maxwin.view.XListView>

</LinearLayout>

效果运行了就知道啦;哈哈;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/7f9af977b63f35b67d5952bd2a6ab86c.html