简体   繁体   English

如何在Android中的可扩展列表视图中单击后禁用子项

[英]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) . 并从调用中获取View,通过调用view.setEnabled(false)禁用它。 I hope this helps 我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在展开式列表视图中添加子项? 安卓系统 - How to add Child Item in an expandable listview? Android Android:单击后禁用ListView? - Android: Disable ListView once clicked? 单击展开式列表视图中的子项时如何在另一个活动中打开列表视图 - How to open a listview in another activity when a child item in an expandable listview is clicked 单击可扩展列表视图项/子项以及如何在此处实施Toast时无法启动/打开活动 - Couldn't start/open an activity when expandable listview item/child clicked and how to implement Toast here 在可扩展ListView Android中更改单击子项的背景颜色 - Change Background Color of Clicked Child in Expandable ListView Android 当在扩展列表视图中单击“子项”中的按钮时,Android更改父项的背景 - Android Change Background of Parent when Button in Child is clicked in Expandable ListView 单击Android时如何从ListView中禁用项目 - How to disable item from listview when he is clicked android 如何在android中的expandable listview中设置子项限制 - How to set a limit for the child in expandable listview in android 如何在android中获取可扩展listview的子值? - how to get child value of expandable listview in android? 如何在Android的Expandable ListView的子项中添加imagebutton? - How to Add imagebutton to child of Expandable ListView on Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM