res/drawable/listview_selector.xml 的内容如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/holo_green_light" android:state_checked="true"/>
<item android:drawable="@android:color/holo_green_light" android:state_pressed="true"/>
</selector>
打包到 apk 后,如果需要按 raw 格式读取,代码如下:
InputStream is = ctx.getResources().openRawResource(R.drawable.listview_selector);
byte[] rawdata = new byte[is.available()];
is.read(rawdata);