如何处理的Android SimpleExpandableListAdapter项选择 [英] How to handle Android SimpleExpandableListAdapter entry selection
问题描述
我在使用SimpleExpandableListAdapter类型的Android应用程序创建可扩展列表。
但我完全茫然,我怎么检测活动时,已经选择了子项之一/点击。
I have created an expandable list in my Android application using the SimpleExpandableListAdapter type. But I'm at a complete loss as to how I detect events when one of the child entries has been selected/clicked.
我已经尝试了所有常用的OnClickListener / OnChildClickListener等,但似乎无法找到(通过实验,或一个小时的谷歌搜索一半)正确的处理程序应该是什么。
I've tried all the usual OnClickListener/OnChildClickListener etc, but can't seem to find (by experimentation, or half an hour googling) what the correct handler routines should be.
任何帮助greatfully AP preciated。
Any help greatfully appreciated.
推荐答案
它应该是:
list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
public void onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Object o = (Object)adapter.getChild(groupPosition, childPosition);
// perform work on child object here
}
}
虽然,这听起来像你尝试过这... <一个href=\"http://developer.android.com/reference/android/widget/ExpandableListView.OnChildClickListener.html\"相对=nofollow> ExpandableListView.OnChildClickListener 说,这是,其实办法做到这一点。
Though, it sounds like you tried this... ExpandableListView.OnChildClickListener says that it is, in fact, the way to do it.
另外,你定义的方法allItemsAreEnabled()和/或isEnabled()为您ListAdapter?你不应该有,但也许他们目前定义并返回错误的值?
Also, have you defined the methods allItemsAreEnabled() and/or isEnabled() for your ListAdapter? You shouldn't have to, but maybe they are currently defined and returning the wrong values?
这篇关于如何处理的Android SimpleExpandableListAdapter项选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!