可扩展列表视图中的设置适配器与列表视图中的设置适配器不同?
setadapter in expandablelistview different from setadapter in listview?
我想在更新日期(添加或删除)后清除列表视图。
我在这里使用了 setadapter How to clear the views which are held in the ListView's RecycleBin?
expList = (ExpandableListView) findViewById(R.id.expandableList);
expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
expListAdapter = expList.getAdapter();
expList.setAdapter (expListAdapter);
但是没用,视图是添加所有数据和更新数据(不是刷新),expandablelistview中的setadapter和listview中的setadapter有什么不同吗?
注意:POIExpandableListAdapter 是 class 扩展 BaseExpandableListAdapter
去掉expListAdapter = expList.getAdapter();
就在 expList = (ExpandableListView) findViewById(R.id.expandableList);
之后,getAdapter()
返回 null 覆盖 expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
。你写的方式等于调用 expList.setAdapter (null);
只需删除 expListAdapter = expList.getAdapter();
您的列表还没有适配器,因此在 setAdapter()
之前调用 getAdapter()
将 return 一个 null 对象。
像这样更改您的代码:
expList = (ExpandableListView) findViewById(R.id.expandableList);
expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
expList.setAdapter (expListAdapter);
最后我找到了如何刷新我的列表(更新后清除以前的数据),在我的情况下我需要在更新数据后再次重新创建向量,而不仅仅是适配器:
vector = new Vector<ArrayList<PointOfInterest>>();
type = new Vector<String>();
expList.setGroupIndicator(null);
expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
expList.setAdapter (expListAdapter);
我想在更新日期(添加或删除)后清除列表视图。 我在这里使用了 setadapter How to clear the views which are held in the ListView's RecycleBin?
expList = (ExpandableListView) findViewById(R.id.expandableList);
expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
expListAdapter = expList.getAdapter();
expList.setAdapter (expListAdapter);
但是没用,视图是添加所有数据和更新数据(不是刷新),expandablelistview中的setadapter和listview中的setadapter有什么不同吗?
注意:POIExpandableListAdapter 是 class 扩展 BaseExpandableListAdapter
去掉expListAdapter = expList.getAdapter();
就在 expList = (ExpandableListView) findViewById(R.id.expandableList);
之后,getAdapter()
返回 null 覆盖 expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
。你写的方式等于调用 expList.setAdapter (null);
只需删除 expListAdapter = expList.getAdapter();
您的列表还没有适配器,因此在 setAdapter()
之前调用 getAdapter()
将 return 一个 null 对象。
像这样更改您的代码:
expList = (ExpandableListView) findViewById(R.id.expandableList);
expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
expList.setAdapter (expListAdapter);
最后我找到了如何刷新我的列表(更新后清除以前的数据),在我的情况下我需要在更新数据后再次重新创建向量,而不仅仅是适配器:
vector = new Vector<ArrayList<PointOfInterest>>();
type = new Vector<String>();
expList.setGroupIndicator(null);
expListAdapter = new POIExpandableListAdapter(LocationSettingActivity.this);
expList.setAdapter (expListAdapter);