pulltorefresh中PullToRefreshExpandableListView使用介面卡的一些問題
阿新 • • 發佈:2018-12-10
pulltorefresh是一個非常強大的上拉載入下拉重新整理的超級開源庫,其中sample中的PullToRefreshExpandableListView例子,他的介面卡可以使用是因為,他本身就是一個繼承於ExpandableListActivity。其中原始碼可以看到
它裡面是有這個介面卡方法,然而有的時候需要在Fragment裡面使用PullToRefreshExpandableListView,該如何呢,pulltorefresh有一個/** * Provide the adapter for the expandable list. */ public void setListAdapter(ExpandableListAdapter adapter) { synchronized (this) { ensureList(); mAdapter = adapter; mList.setAdapter(adapter); } }
類
就是使用在Fragment,而這個我似乎並不行,那麼就只能用第二種方法* @author Chris Banes * */ public class PullToRefreshExpandableListFragment extends PullToRefreshBaseListFragment<PullToRefreshExpandableListView> { protected PullToRefreshExpandableListView onCreatePullToRefreshListView(LayoutInflater inflater, Bundle savedInstanceState) { return new PullToRefreshExpandableListView(getActivity()); } }
通過PullToRefreshExpandableListView.getRefreshableView();來獲得ExpandableListView的例項,然後用ExpandableListView的例項來進行資料的載入即可