我想禁用当触摸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禁用焦点高亮,
当你设置你的ListAdapter使用下面的代码
ListAdapter adapter = new SimpleCursorAdapter(MyList, Layout, c,
new String[] { "Name", "Score" }, to)
{
public boolean areAllItemsEnabled()
{
return false;
}
public boolean isEnabled(int position)
{
return false;
}
};
这将覆盖BaseAdapter类。它还取消了单元格之间的白色边界。
其他回答
RoflcoptrException的答案应该做的把戏,但出于某种原因,它不为我工作,所以我张贴的解决方案,为我工作,希望它能帮助别人
<ListView
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
/>
在代码中
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>
有一种快速简单的方法: 方法:
private void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
//TODO
((ListView)sender).SelectedItem = null;
}
希望能有所帮助;)
作为替代:
listView.setSelector(android.R.color.transparent);
or
listView.setSelector(new StateListDrawable());
没有什么能帮助我,只有这个:
transparent_drawable.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
</shape>
layout.xml:
android:listSelector="@drawable/transparent_drawable"