Android 在没有自定义列表视图适配器的情况下设置列表视图单元格的元素

发布于 2024-12-01 06:18:38 字数 272 浏览 5 评论 0原文

我想做类似 mylistview.setElementsofView(0).getElementById.setColor("black");

目前我知道这样做的唯一方法是设置自定义列表视图适配器,设置构造函数,进行条件检查以查看视图是否已填充,然后在该视图中执行操作,

这看起来非常复杂,而列表视图的其他部分很容易访问。

是否有一些我可以在列表视图中访问的继承函数,以允许我在没有自定义适配器的情况下访问特定视图的元素?

感谢您的任何见解

I want to do something like mylistview.setElementsofView(0).getElementById.setColor("black");

currently the only way I know of doing this is setting up a custom list view adapter, setting up constructors, do conditional checks to see if view is populated, then do stuff in that view

this seems very convoluted, when other parts of the listview are so easily accessible.

is there some inherited function I can access in listview to allow me to access the elements of a particular view without a custom adapter?

Thanks for any insight

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

注定孤独终老 2024-12-08 06:18:38

对你的问题的简短回答:

is there some inherited function I can access in listview to allow me to access the elements of a particular view without a custom adapter?

不幸的是,答案是否定的。

您认为为什么设置自定义适配器如此复杂?只需将自定义适配器类设置为活动中的嵌套类即可。最有可能的是,您只想重写 getView() 方法。最后,与寻找“简单”解决方案相比,您花在这方面的时间会少得多。

The short answer to your question:

is there some inherited function I can access in listview to allow me to access the elements of a particular view without a custom adapter?

unfortunately is no.

Why do you think setting up a custom adapter is so convoluted? Just make the customized adapter class a nested class within your activity. Most likely, you'd only be looking at overriding the getView() method. In the end, you'll spend a lot less time doing this than looking for a "simple" solution.

别忘他 2024-12-08 06:18:38

怎么样

myListView.getChild(index).setColor("black");

What about

myListView.getChild(index).setColor("black");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文