0

如何从可扩展的列表视图 android 中获取子位置。

我想自动从可扩展列表视图 setSelect 中获取子位置。

4

2 回答 2

4
 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;
            }
        });
于 2013-09-19T06:15:24.710 回答
0

您必须使用适配器的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);
 }
于 2013-09-19T06:18:44.567 回答