手动调用 onListItemCLick
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过大量搜索后,解决方案不是进行手动调用,而是重写适配器 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()