简体   繁体   中英

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

您可以在适配器或任何地方存储禁用位置列表,并检查该项是否已禁用,如果单击该项,则不执行任何操作。

Set listener

and get View from call, disable it by calling view.setEnabled(false) . I hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM