我有一个 Activity extends ListActivity
。
ListView 使用默认主题的颜色。如何将我自己的颜色状态列表资源设置为 ListView?
我试过这个onCreate()
:
getListView().setBackgroundResource(R.drawable.background_listview);
这是 background_listview
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ff000000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff000000"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
但我只得到错误
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <item> tag
requires a 'drawable' attribute or child tag defining a drawable.