I have a drawer layout inside it I have ListView with custom selector that gives the selected item some color. when drawerlayout is open, clicking any items changes its color based on selector but after closing the drawerlayout somehow the selected list item loses its state. All list items is getting default state. How can I keep state for listitem in listview after closing drawerlayout?
Asked
Active
Viewed 40 times
0
-
ListView has a [setSelection()](https://developer.android.com/reference/android/widget/ListView.html#setSelection(int)) method. You could try that. – Gary99 Jul 31 '17 at 15:56
-
Yes I can set selection but after closing drawer all selections are cleared – mister_giga Jul 31 '17 at 15:59
-
Is your `ListView` like the `app:menu` of `NavigationView`? Why don't you use menu? In case I misunderstand your question, could you please show your layout? Also, as for your question itself, you can refer to this case: [Android - Keep ListView's item highlighted once one has been clicked](https://stackoverflow.com/questions/9281000/android-keep-listviews-item-highlighted-once-one-has-been-clicked). – Grace Feng Aug 01 '17 at 06:04