在可扩展列表视图中获取子名称而不是位置ID

时间:2014-07-21 14:53:17

标签: android expandablelistview

我正在关注this教程以实现可扩展列表视图。现在我的问题是,如何更改以下方法以获取子名称而不是子位置ID?

// Call when child row clicked
        @Override
        public long getChildId(int groupPosition, int childPosition) {
            /****** When Child row clicked then this function call *******/

            // Log.i("Noise",
            // "parent == "+groupPosition+"=  child : =="+childPosition);
            if (ChildClickStatus != childPosition) {
                ChildClickStatus = childPosition;

                Toast.makeText(
                        getApplicationContext(),
                        "Parent :" + groupPosition + " Child :" + childPosition,
                        Toast.LENGTH_LONG).show();

            }

            return childPosition;
        }

我已经尝试了2个小时才能完成这项工作。

1 个答案:

答案 0 :(得分:0)

将此作为孩子使用并在此处声明

getChildId(int groupPosition, int childPosition) { 
    final Child child = parent.getChildren().get(childPosition);
    //The rest of your method...
}