我想禁用当触摸listView行时出现的橙色高亮。到目前为止,在我的xml我已经尝试了以下:
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
更多信息:我希望当用户在这个listView对象上触摸屏幕时,没有任何差异。
我想禁用当触摸listView行时出现的橙色高亮。到目前为止,在我的xml我已经尝试了以下:
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
更多信息:我希望当用户在这个listView对象上触摸屏幕时,没有任何差异。
当前回答
作为替代:
listView.setSelector(android.R.color.transparent);
or
listView.setSelector(new StateListDrawable());
其他回答
如果要禁用单个列表视图项的高亮显示,但保持单元格启用,请设置该单元格的背景颜色以禁用高亮显示。
例如,在你的单元格布局中,设置android:background="@color/white"
RoflcoptrException的答案应该做的把戏,但出于某种原因,它不为我工作,所以我张贴的解决方案,为我工作,希望它能帮助别人
<ListView
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
/>
把这个添加到你的xml中:
android:listSelector="@android:color/transparent"
对于这个问题,这可能会起作用(我不确定,我不知道是否有更好的解决方案):
你可以应用一个ColorStateList到你的TextView。
你只需要添加: android: cacheColorHint = " @android:颜色/透明”
在虚拟和真实设备上进行了一些“谷歌”测试后,我注意到下面的代码是有效的:
ArrayAdapter<String> myList = new ArrayAdapter<String>(this, R.layout.list_item, strText) {
public boolean isEnabled(int position)
{
return false;
}
};
注意,我省略了areAllItemsEnabled()部分。