如何从可扩展的列表视图 android 中获取子位置。
我想自动从可扩展列表视图 setSelect 中获取子位置。
expListView.setOnChildClickListener(new OnChildClickListener() {
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
final String selected = (String) expListAdapter.getChild(
groupPosition, childPosition);
Toast.makeText(getBaseContext(), selected, Toast.LENGTH_LONG)
.show();
return true;
}
});
您必须使用适配器的getChild(groupPosition, childPosition)
方法来检索子实例。
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(this, (String)((Map<String, String>)
adapter.getChild(groupPosition, childPosition)).get(childPosition),
Toast.LENGTH_LONG).show();
return super.onChildClick(parent, v, groupPosition, childPosition, id);
}