I have extended a cursor adapter
public class MyAdapter extends CursorAdapter {
MyAdapter(View view, Context context, Cursor cursor) {
...
}
public void bindView(View view, Context con, Cursor c) {
if (OtherClass.currentlyPlaying.equals(ring)) {
TextView.setTextColor(Color.red);
}
}
}
The ‘currentlyPlaying’ is a string in another class that corresponds with a title that is currently playing. The ‘ring’ is a title that is found when binding the view in the adapter. I have the textview change color when it’s selected. When it’s selected it changes colors, but when I click another item in the listview it changes color too, but the old item that was selected remains the same color.
Can anyone tell me if there is a way to update the view or how I would be able to apply maybe a viewholder to this? Thanks!
try using the else{} part of your “if” and set it to the default color. Something like
From what I get is that the old item is not getting redrawn. ViewHolder could mostly help you too but for that you need to implement it. You could try the following tutorial in this thread.
https://stackoverflow.com/a/9696185/1244489
You might find it useful.