代码之家  ›  专栏  ›  技术社区  ›  Sini Inis

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

  •  -1
  • Sini Inis  · 技术社区  · 12 年前

    我在关注 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;
            }
    

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

    1 回复  |  直到 12 年前
        1
  •  0
  •   Robin Ellerkmann middleseatman    12 年前

    把这个当作孩子,把声明放在这里

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