1
我已經構建了以下說明的可搜索ExpandableListView在Android ExpandableListView Search Filter Example但我掙扎,選擇正確的兒童在使用onChildClick()ExpandableListView搜索過濾器
當目前我使用下面的代碼來選擇和發送信息發展到新的意圖。但是,當應用搜索過濾器時,會發送該位置的原始子女的信息,而不是來自過濾列表中的子女的信息。
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;
}
});
你的假設是正確的!使用適配器方法代替解決了問題。 –