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

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

问题描述

我有一个 ListActivity 实现 onListItemClick()并调用 DoSomething的() 函数的类。后者包含 l.setSelection(位置),其中的ListView 对象。

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()监听按钮点击该perfoms一些行动,而且也要求 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?

推荐答案

也许你需要使用的功能:

maybe you need to use function:

ListView.setItemChecked(int position, boolean checked);

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

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