Drawable Resource Not Found
Wszystkie próbuję zaimplementować zasób do losowania selektora dla niestandardowegoArrayAdapter
. Konsekwentnie otrzymujęandroid.content.res.Resources$NotFoundException: File res/drawable/list_selector.xml from drawable resource ID #0x7f020
Czy ktoś może zaproponować sugestie?
Mam dwa pliki XML:
res / drawable / list_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:color="@android:color/white" />
<item android:state_checked="false" android:color="@android:color/black" />
</selector>
res / layout / list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/casualty_text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/list_selector"/>
</LinearLayout>
Wreszcie mój kod ładuje element listy w następujący sposób:
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TCCC cur_object = getItem(position);
View cur_view = convertView;
if(cur_view == null)
{
System.out.println("Inflating!");
cur_view = View.inflate(getContext(), R.layout.list_item, null);
String text_value = (cur_object.m_name.length() == 0) ? "New Casualty" : cur_object.m_name;
TextView name_box = (TextView)cur_view.findViewById(R.id.casualty_text_view);
if(name_box != null)
name_box.setText(text_value);
}
return cur_view;
}