手动调用 onListItemCLick

发布于 2024-09-18 14:06:53 字数 332 浏览 12 评论 0原文

我正在使用 ListView 和 SimpleAdapter。一旦数据填充到其中,我想设置列表中的第一项。这可以通过单击屏幕上的列表项来完成。我想在填充列表后直接调用该方法,这样当您看到 UI 时它已经完成了。我唯一的问题是从 ListView 获取视图。我注意到它的子项都是空的,但 SimpleAdapter 中有项目。当我尝试获取这些项目时,它们不是视图,并且我无法匹配方法调用,

protected void onListItemClick(ListView l, View v, int position, long id)

因为我无法获取正确的视图。任何帮助将不胜感激。

I am using a ListView with a SimpleAdapter. Once data is populated into it I would like to set the first item in the list. This can be done by clicking on the list item on the screen. I want to just call the method directly after I populate the list so that when you see the UI its already done. My only problem is getting the View from the ListView. I noticed its children are all null but the SimpleAdapter has items in it. When I try to get those items they are not Views and I am not able to match the method call of

protected void onListItemClick(ListView l, View v, int position, long id)

because I cant get the right View. Any help would be appreciated.

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

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

发布评论

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

评论(1

短暂陪伴 2024-09-25 14:06:53

经过大量搜索后,解决方案不是进行手动调用,而是重写适配器 getView 方法。这样我就可以更改背景颜色,而不必手动调用 onListItemClick()

After lots of searching the solution is not to make a manual call but to override the adapter getView method. That way I can change the background color and not have to manually call onListItemClick()

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