why does Listview + Selector crash from xml file -


i have list view, want background change color when clicked (touched) user.

each listitem fallows:

<?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> 

inside drawable have fallowing file (row_background.xml):

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:state_focused="true" android:background="@color/white" />     <item android:state_focused="true" android:state_pressed="true" android:background="@color/green" />     <item android:state_pressed="true" android:background="@color/green" />     <item android:background="@color/white" /> </selector> 

and have color file inside values folder (color.xml):

<?xml version="1.0" encoding="utf-8"?>  <resources>     <color name="green">#808080</color>     <color name="white">#ffffff</color> </resources> 

when try run colors selector crashes. if run white background, without calling selector works ok.

can tell me wrong?

thanks, adrian.

codes colors in xml wrong... need add '#ff' before code...

<?xml version="1.0" encoding="utf-8"?>      <resources>     <color name="green">#ff808080</color>     <color name="white">#ffffffff</color>     </resources> 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -