You must write a custom adapter that extends the BaseAdapter for your ListView. To disable certain elements, you need to override "boolean isEnabled (int position)" in this adapter and return false for each position that you want to disable.
As for changing the background color for certain list items: you can save the background color value in the displayed data structure. In the getView () method of your custom adapter, you must check this color value for the current element and return the view with the correct background color.
Or you can simply call 'getChildAt ()' on the ListView, return the View object for the desired item in the list, and change its background color. I think I would rather use the previous solution.
Remember to call "notifyDataSetChanged ()" in your ListView adapter after making such changes.
source
share