我按照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;
}
});