An Android customed ListView that could auto load more data 自定义ListView,可以自动加载更多。
Use the customed view in xml layout file like that
<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"
tools:context=".MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.lance.autoloadlistview.AutoLoadListView
android:id="@+id/lv_data"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
Find view and set listener for load more.The Activity or the Fragment should implements AutoLoadListView.IonLoadMore.
AutoLoadListView mLvData = (AutoLoadListView) findViewById(R.id.lv_data);
mLvData.setOnLoadmoreListener(this,mContext);
Set the adapter.When the AutoLoadListView scroll to the bottom,it would call the method onLoadMore();
mAdapter = new ArrayAdapter(mContext,android.R.layout.simple_list_item_1,android.R.id.text1,data);
mLvData.setAdapter(mAdapter);