I have created a custom selector for my listview which changes the background color of the list item using a drawable. I previously having issues with the background color extending to random views in the list when scrolling and I fixed this by making the view in the adapter always null however when I scroll and as soon as the item is no longer visible the background color that was set is no longer there, it's like it's not remembering it. This is probably due to the view being null always?
I am basically wanting the item selected to be changed and not affect other items in the list and when scrolling, the item that was changed should be remembered.
public View getView(int pos, View view, ViewGroup viewgroup)
{
View row = null;
view = null;
row = view;
if(view == null)
row = layoutInflater.inflate(R.layout.layout_list, viewgroup, false);
row.setPadding(0, 10, 0, 10);
listText = (MusicTextView)row.findViewById(R.id.listLabels);
listText.setTypeface(Typeface.createFromAsset(
context.getAssets(),
"fonts/Roboto-Light.ttf"
return row;
}