安卓:到ListView打开时为选择设置项目? [英] Android:To set an item as selected when the ListView opens?

查看:88
本文介绍了安卓:到ListView打开时为选择设置项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是活动有一个按钮和一个ListView。 最初,只有按钮是可见的。当按钮pssed $ P $,则显示的ListView。 在显示时,有可能是我的选择显示一个特定的项目/集中?

An activity has a Button and a ListView. Initially, only the Button is visible. When the button is pressed, the ListView is displayed. When displayed, is it possible for me to show one particular item as selected/focussed?

一个用例可能是假设它是语言设置的列表,并将列表打开时,当前选择的语言必须显示为高亮显示。

A use case could be that suppose it is a list of language settings and when the list opens, the currently selected language must be shown as highlighted.

如果我知道这个项目的索引,如何将它设置为集中展示?

If I know the index of the item, how to set it as focused on display?

推荐答案

总之,ListView控件:: setSelection(INT位置)是你所需要的。然而,根据设备是否处于触摸模式或不是,它可以或可以不具有视觉效果(背景高亮)。欲了解更多详情,请参阅<一个href="http://stackoverflow.com/questions/2042278/android-listview-selection-problem">http://stackoverflow.com/questions/2042278/android-listview-selection-problem

In short, ListView::setSelection(int position) is what you need. However, depending on whether the device is in touch mode or not, it may or may not have visual effect (background highlighting). For more details, refer to http://stackoverflow.com/questions/2042278/android-listview-selection-problem

这篇关于安卓:到ListView打开时为选择设置项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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