listview项SetBackgroundResource

时间:2015-03-06 14:06:15

标签: android xamarin

我有一个ListView,我想将默认颜色覆盖为我的自定义颜色(点击时)。我创建了xml文件: BlueBackground.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@color/pressed_color" /> <!-- focused -->
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@color/pressed_color" /> <!-- focused and pressed-->
    <item android:state_pressed="true" android:drawable="@color/pressed_color" /> <!-- pressed -->

</selector> 

colors.xml

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <color name="pressed_color">#4d90fe</color>
</resources>

将后台资源设置为listview:

nativeListview.SetSelector (Android.Resource.Drawable.BlueBackground);

虽然点击它可以很好地工作,但是当我按下默认颜色(&#34;橙色&#34;)时会出现一段时间。

如何删除橙色?

0 个答案:

没有答案