【发布时间】:2015-08-14 14:37:54
【问题描述】:
我按照Android ExpandableListView Search Filter Example 的说明构建了一个可搜索的 ExpandableListView,但在使用 onChildClick() 时我很难选择正确的子项
目前,我正在使用下面的代码来选择信息并将其发送到新意图。但是,当应用搜索过滤器时,会发送该位置的原始孩子的信息,而不是过滤列表中的孩子的信息。
myList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Object a = continentList.get(groupPosition).getCountryList().get(childPosition).getCode();
Object b = continentList.get(groupPosition).getCountryList().get(childPosition).getName();
Object c = continentList.get(groupPosition).getCountryList().get(childPosition).getPopulation();
// Start new intent
Intent intent = new Intent(SearchActivity.this, DisplayCountry.class);
intent.putExtra("code", ""+ a);
intent.putExtra("name", "" + c);
intent.putExtra("population", "" + b);
startActivity(intent);
return true;
}
});
【问题讨论】:
标签: android expandablelistview listadapter expandablelistadapter