android - Highlight a row in listview -


i creating listview reference this link. trying highlight particular row in listview. when pressing button particular row got highlighted second. want row should stay in same color until presses button in next row. listview is

<listview         android:id="@+id/mainlistview"         android:layout_width="154dp"         android:layout_height="fill_parent"         android:layout_margin="10dp"         android:background="@drawable/layer_list"         android:dividerheight="2px"         > 

and in listview placing textview , imageview. highlighting view followed this tutorial. new android. me in achieving this. in advance..

create selector in draw-able folder listview_item_selection_effect.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:state_focused="true">     <shape>         <solid android:color="#ffffff" />     </shape> </item>     <item>     <shape>         <solid android:color="#00a7eb" />     </shape> </item> </selector> 

in layout has listview

android:background="?android:attr/activatedbackgroundindicator" 

in activity on listview item clicked

   listview.setonitemclicklistener(new onitemclicklistener(){     @override      public void onitemclick(adapterview<?> arg0, view arg1,int position, long arg3){         listview.setselector(r.drawable.listview_item_selection_effect);     listview.setitemchecked(position,true);     } }); 

in listview

android:choicemode="singlechoice" 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -