安卓:禁用的ListView选择 [英] Android: disable ListView selection
问题描述
我有一个ListView,我再次显示了正确的答案,当用户选择突出显示的项目。然而,在这一点上,我想禁用选择列表视图中的项目;用户只能得到由pressing一个按钮,下一个问题。不过,即使我禁用,像这样的项目:
I have a listView that I re-display with the correct answer highlighted when the user selects an item. However, at that point I would like to disable selection of list view items; the user can only get to the next question by pressing a button. However, even if I disable the items like so:
private void disableItemSelection() {
ListView lv = getListView();
for (int i = 0; i < lv.getChildCount(); i++){
View v = lv.getChildAt(i);
v.setEnabled(false);
}
}
...它仍然凸显了选择当用户选择它。有什么想法吗?
...it still highlights the selection when the user selects it. Any thoughts?
推荐答案
滚动锁定的原因是因为您要设置为
The reason the scrolling is locked is because you are setting up at
ListView
我找到了一种方法来禁用突出不锁定卷轴。您需要将其设置为ListAdapter如下图所示:
I found a way to disable highlighting without locking the scroll. You need to set it up at ListAdapter as shown below:
ArrayAdapter<String> myList = new ArrayAdapter<String>(this, R.layout.list_item, strText) {
public boolean isEnabled(int position)
{
return false;
}
};
这篇关于安卓:禁用的ListView选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!