[英]How to disable a child item once clicked in an expandable listview in Android
I have an expandable listview with Questions and I want each time a question is clicked or answered to have this child question disabled. 我有一个可扩展的列表视图与问题,我希望每次点击或回答问题,以禁用此子问题。 Is this possible? 这可能吗? thank you 谢谢
This is what I have done do far 这就是我所做的
expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,int groupPosition, int childPosition, long id)
{
boolean GroupExists = linkedHashMapobject.containsKey(groupPosition);
boolean ChildExists = linkedHashMapobject.containsValue(childPosition);
if(GroupExists || ChildExists)
{
Toast.makeText(getContext(),"It already exists",Toast.LENGTH_LONG);
}else
{
v.setEnabled(false);
linkedHashMapobject.put(groupPosition,childPosition);
CollectData(childPosition,groupPosition);
}
return true;
}
});
which does not work and disables all child elements 这不起作用并禁用所有子元素
您可以在适配器或任何地方存储禁用位置列表,并检查该项是否已禁用,如果单击该项,则不执行任何操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.