【问题标题】:Android Detect ChildClick in ExpandableListViewAndroid 在 ExpandableListView 中检测 ChildClick
【发布时间】:2012-07-12 10:37:02
【问题描述】:

这是我的应用程序的屏幕截图,当在 ExpandableListView 中单击任何子项时,特定条目的详细信息会显示在右侧。

用户可以在右侧编辑每个孩子的详细信息,并使用后退按钮保存详细信息。

现在,我想要实现的是,当用户点击另一个孩子时,对前一个条目所做的编辑也应该被保存。

我没有附上我的代码,因为代码真的很长很复杂。为了简化问题,假设我将所有条目存储在一个名为“SlotList”的二维数组中,每当单击任何子项时,我都会将该子项的详细信息复制到一个对象(名为 CurrentSlot)中,并对数据成员执行编辑当前插槽。现在,当用户按下 BackButton 时,我通过 SaveCurrentSlot(Slot object) 保存 CurrentSlot 的详细信息。

当用户单击 ExpandableList 中的另一个子项时,我想要调用 SaveCurrentSlot(Slot obj)。

关于我应该如何做的任何建议/提示?

提前致谢。 :)

【问题讨论】:

    标签: android expandablelistview


    【解决方案1】:

    我认为最好使用 onChildClick 方法来满足您的要求。

     >>Basing on the child click position you can set data to layout right.
    

    使用这个方法

     public boolean onChildClick( ExpandableListView parent, View v, int groupPosition,int childPosition,long id) {
        System.out.println("Inside onChildClick at groupPosition = " + groupPosition +" Child clicked at position " + childPosition);
    
        //ur code here
    
        return true;
    }
    

    有关可展开列表视图中的子点击的更多详细信息,请访问this

    【讨论】:

    • 我知道我必须使用 onChildClick。你不明白我的问题。我需要检测是否点击了其他孩子而不是已经显示的孩子。
    • 这个权限可以得到父位置和子位置。那么这些值是否对您查找点击了哪个孩子没有帮助
    猜你喜欢
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多