[英]How to disable a child item once clicked in an expandable listview in Android
我有一個可擴展的列表視圖與問題,我希望每次點擊或回答問題,以禁用此子問題。 這可能嗎? 謝謝
這就是我所做的
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;
}
});
這不起作用並禁用所有子元素
您可以在適配器或任何地方存儲禁用位置列表,並檢查該項是否已禁用,如果單擊該項,則不執行任何操作。
設置監聽器
並從調用中獲取View,通過調用view.setEnabled(false)
禁用它。 我希望這有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.