为什么Listview+;xml文件中的选择器崩溃
我有一个列表视图,当用户点击(触摸)背景时,我希望背景改变颜色 每个列表项都作为休耕:为什么Listview+;xml文件中的选择器崩溃,xml,listview,crash,selector,Xml,Listview,Crash,Selector,我有一个列表视图,当用户点击(触摸)背景时,我希望背景改变颜色 每个列表项都作为休耕: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/row_item" android:layout_width="fill_parent" android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/row_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/row_background">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/RowImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight = "1"
android:background="#ffffff"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:minHeight="48dp"
android:maxHeight="48dp" />
<TextView android:id="@+id/RowText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="16dp"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#000080"
android:background="#ffffff"
android:layout_weight = "2" />
</LinearLayout>
</LinearLayout>
在drawable中,我有一个fallowing文件(row_background.xml):
然后我在values文件夹(color.xml)中有一个颜色文件:
#808080
#ffffff
当我尝试使用颜色选择器运行时,它崩溃了。如果我只在白色背景下运行,而不调用选择器,一切正常
谁能告诉我怎么了
谢谢,
Adrian.XML中的颜色代码错误。。。您需要在代码前添加“#FF”
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="green">#FF808080</color>
<color name="white">#FFFFFFFF</color>
</resources>
#FF8080
#FFFFFFFF
XML中颜色的代码错误。。。您需要在代码前添加“#FF”
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="green">#FF808080</color>
<color name="white">#FFFFFFFF</color>
</resources>
#FF8080
#FFFFFFFF
您能解释一下为什么您认为这是解决方案吗?您能解释一下为什么您认为这是解决方案吗?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="green">#FF808080</color>
<color name="white">#FFFFFFFF</color>
</resources>