Android:如何使 ExpandableListView 中的子行不可点击?
我想这很简单,但搜索没有帮助...
我想要一个 ExpandableListView,您无法在其中选择子行。
我尝试将选择器设置为“透明”,但它仍然更改了文本颜色,因此您会注意到您已单击。
亲切的问候, 海蜇
Guess this is pretty simple, but searching didn't help...
I want an ExpandableListView, where you can not select the child rows.
I tried to set the selector to "transparent", but it still changed the text color, so you would notice that you've clicked.
Kind regards,
jellyfish
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你太晚了,但我希望它能帮助别人。
您必须在适配器中实现此方法:
If you too late, but I hope it helps someone.
You must implement this method in your adapter:
您是否尝试在子视图上添加 setFocusable(false) 参数?还将文本颜色更改为黑色。默认情况下有一个选择器黑色默认为白色按下。所以基本上将子视图的每种颜色更改为不可选择的颜色。
have you tried to add the setFocusable(false) param on the child views? also change the text color to black. the default has a selector black default to white pressed. so basically change every color of the child view to a non selectable one.
我意识到,在大多数 Android 应用程序(例如我自己手机上的设置)中,显然没有人愿意关闭“点击”动画,即使之后没有任何操作。因此我也决定就这样保留下去。
I realized that in most Android apps (e.g. the settings on my own phone) apparently nobody bothers to switch off the "click" animation even if there is no action afterwards. Therefore I decided to just leave it this way, too.