我想使用Activity扩展ListActivity for PullToRefresh.But我使用CustomActionBar这就是使用AppCompatActivity.How来解决这个问题的原因.谢谢你在Advanced中
public class CustomActionActivity extends ListActivity
public class PullToRefreshActivity extends ListActivity {
private LinkedList mListItems;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pull_to_refresh);
// Set a listener to be invoked when the list should be refreshed.
((PullToRefreshListView) getListView()).setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {
@Override
public void onRefresh() {
// Do work to refresh the list here.
new GetDataTask().execute();
}
});
mListItems = new LinkedList();
mListItems.addAll(Arrays.asList(mStrings));
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, mListItems);
setListAdapter(adapter);
}
而不是这个:
public class CustomActionActivity extends AppCompatActivity
本文探讨了如何在继承自 AppCompatActivity 的CustomActionActivity中集成PullToRefresh功能,同时保持ActionBar的自定义。作者分享了如何在清单文件中设置监听器和适配器,以实现列表刷新操作,即便在使用AppCompatActivity作为父类时。
1997

被折叠的 条评论
为什么被折叠?



