我想禁用当触摸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());
其他回答
如果使用ArrayAdapter或BaseAdapter填充列表项。重写isEnabled方法并返回false。
@Override
public boolean isEnabled (int position) {
return false;
}
在代码中
listView.setSelector(getResources().getDrawable(R.drawable.transparent));
并添加小透明图像到可绘制文件夹。
如: transparent.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
</shape>
把这个也添加到你的XMl和listselector..希望它会工作
<ListView
android:cacheColorHint="@android:color/transparent"
android:listSelector="@android:color/transparent"/>
如果要禁用单个列表视图项的高亮显示,但保持单元格启用,请设置该单元格的背景颜色以禁用高亮显示。
例如,在你的单元格布局中,设置android:background="@color/white"
对于我android:focusableInTouchMode="true"是去的方式。android:listSelector="@android:color/transparent"没有用。注意,我使用的是一个自定义的列表视图,每行都有一些对象。