我可以找到基于文本的可扩展列表视图项吗
这个 sudo 代码可以吗?
for (all children in my custom expandable list) {
if (childItemText.equals("This string") {
viewWithTextIWant.setBackgroundResource(R.color.blue)
}
}
我不知道如何编码。如果您需要任何说明,请告诉我。
Is this sudo code possible?
for (all children in my custom expandable list) {
if (childItemText.equals("This string") {
viewWithTextIWant.setBackgroundResource(R.color.blue)
}
}
I cannot figure out how to code this. Let me know if you need any clarification.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在我的应用程序中做了类似的事情。我浏览了 Android Developer 网站上的 ExpandableListView 小部件。它似乎没有任何 get 方法可以让您比较
ExpandableListView
中项目的字符串值。您需要做的是创建自己的字符串数组来保存您想要的字符串值。然后使用
ExpandableListView
的 get 方法返回所选项目的位置,并将其与字符串数组进行比较。换句话说,get 方法将返回值
"i"
。使用myStringArray[i].equals("This string")
比较字符串值。I've done something similar to this with my app. I've looked through the ExpandableListView widget on the Android Developer site. It doesn't seem to have any get methods that will allow you to compare the string value of the items in your
ExpandableListView
.What you'll have to do is create your own array of strings that hold the string values you want. Then use the get method of
ExpandableListView
that returns the position of the item selected and compare it to your string array.In other words, the get method will return value
"i"
. UsemyStringArray[i].equals("This string")
to compare the string values.这似乎是 Adapter 类中 getChildView 的一项任务。
我对 ExpandableListView 中的组执行了相同的操作:
警告!该代码没有优化,它会膨胀每个项目,这很昂贵。就我而言,我并不担心,因为我的 ExpandableListView 有一些项目
It seems a task for getChildView in your Adapter class.
I've done the same for groups in my ExpandableListView:
Warning! This code is not optimized, it inflates every item, this is expensive. In my case I didn't worry because my ExpandableListView had a few items