本文介绍了Android的ListView控件编程选择/亮点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的ListView和listadapter设置如下:

I have a simple listview and listadapter setup as follows:

listAdapter = new ArrayAdapter<MyDomainObject>(this, android.R.layout.simple_list_item_1, listOfDomainObjects);
listView.setAdapter(listAdapter);

的用户使该他们带到另一个活动列表中进行选择。在新的活动,他们可以点击他们的选择而它们返回到上述列表中的活动。我想强调提出的previous选择。我现在找到匹配的列表条目,并呼吁:

The user makes a selection on the list which takes them to another activity. From the new activity they can click their selection which returns them to the activity with the above list. I want to highlight the previous selection made. I currently find the matching list entry and call:

listView.setSelection(matchIndex);

此带来他们的previous选择到列表的顶部。是否有可能以突出(在默认橙色)的previous选择。我已经试过,没有运气的几种方法。

This brings their previous selection to the top of the list. Is it possible to highlight (in that default orange) the previous selection. I have tried several approaches with no luck.

推荐答案

你有什么是好的。然而,该选择是否被突出的确定用户是否已使用触摸屏来确定。如果它们使用了触摸屏最近比轨迹球/ D垫/不管,该设备处于触摸模式和选择亮点未示出。

What you have is fine. However, the determination of whether the selection is "highlighted" is determined on whether the user was using the touchscreen. If they have used the touchscreen more recently than the trackball/D-pad/whatever, the device is in "touch mode" and selection highlights are not shown.

这篇关于Android的ListView控件编程选择/亮点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:29