开发者

Android:How to retain change in color of ListView row?

开发者 https://www.devze.com 2023-04-11 20:09 出处:网络
In my one of the ListView activity i am cha开发者_如何学Gonging color of 1 or more row on click, but i want to retain this change in color of row, when i come back to this activity again. so how to sa

In my one of the ListView activity i am cha开发者_如何学Gonging color of 1 or more row on click, but i want to retain this change in color of row, when i come back to this activity again. so how to save and retrieve change in color of row in ListActivity


If you want to have your color changed of the clicked rows than, you have to somehow save the state for the rows(if it is clicked or not) as @mak_just4anything suggested to you the best suitable datatype for you is array list of booleans. This list you can save it in sqlite database of maybe use a key value pairs of preferences. But it is very important to note that you need to notify you adapter for the data changed. After the adapter is refreshed ( I guess you will do this in onCreate or in onResume callback) then you will see the listview with right coloring


Take an array of booleans, and make the indexes of items and boolean same, it means you will have boolean array corresponding to the array of items, when ever you click on item change the boolean value to true so it will be saved in that index and whenever you come back you will find the same array with colored items corresponding to the boolean array....!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号