Android ListView setSelection() 似乎不起作用 [英] Android ListView setSelection() does not seem to work

查看:18
本文介绍了Android ListView setSelection() 似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ListActivity 实现 onListItemClick() 并调用类的 doSomething() 函数.后者包含 l.setSelection(position) 其中 lListView 对象.

I have a ListActivity that implements onListItemClick() and calls a doSomething() function of the class. The latter contains l.setSelection(position) where l is the ListView object.

现在有一个 onClickListener() 监听按钮点击,它执行一些动作并且也调用 doSomething().

Now there is a onClickListener() listening for a button click that perfoms some actions and that too calls doSomething().

在第一种情况下,所选项目得到了适当的定位,但在后一种情况下,什么也没有发生.

In the first case, the selected item get positioned appropriately, but in the latter, nothing happens.

关于这种奇怪行为的任何线索以及我如何使它起作用?

Any clues about this strange behaviour and how I might make it work?

推荐答案

也许你需要用到函数:

ListView.setItemChecked(int position, boolean checked);

这篇关于Android ListView setSelection() 似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆