android - ListView item onClick color stays the same for a second after I return to the activity, how to refresh it? -
so using following can change on click color of listview item. however, annoyed @ happening when return activity after click - color stays same when clicked on second , refreshes normal background. also, if hold listview item , slide finger away, listview item stays continuously clicked on , not return until tap on listview item. how can change background color of listview item on tap , not have stay same after switch same activity? here code. thanks!
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background_repeatable" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".categoriesactivity"> <listview android:id="@+id/categorieslist" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:text="@color/white" android:textalignment="center" android:visibility="visible" android:divider="@android:color/transparent" android:dividerheight="10.0sp" android:drawselectorontop="false" android:listselector="@drawable/list_view_item_background_on_click"> </listview> </relativelayout> <?xml version="1.0" encoding="utf-8"?> <!-- layout individual news entries in list --> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/list_view_item_background" android:gravity="center_vertical" android:paddingbottom="8.0dip" android:paddingleft="12.0dip" android:paddingright="3.0dip" android:paddingtop="8.0dip" > <imageview android:id="@+id/imgurl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustviewbounds="true" android:paddingleft="2sp" android:src="@drawable/ic_menu_search_holo_light"> </imageview> <textview android:id="@+id/name" android:layout_width="wrap_content" android:layout_torightof = "@+id/imgurl" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:textcolor="@color/white" android:textsize="20sp" android:textstyle="bold" /> </relativelayout> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="10dp" /> <stroke android:width="0.5dp" android:color="@color/teal" /> <solid android:color="@color/teal" /> </shape>
here seems tutorial want use state drawables
change color in different states such focused, pressed, enabled, disabled
doing way, color change when press on when return state won't pressed default color, believe want.
Comments
Post a Comment