My ListView
contains two Textviews
. In one row first one is for name and second one is for result. I need to change the background color of the re
Set this code on adapter (custom), so you can recycle the view with the previous color only if the view is selected.
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE );
Task task = taskArrayList.get(position);
View view = inflater.inflate(R.layout.task_row, parent, false);
if(MyActivity.getIsClicked() && MyActivity.getPositionClicked() == position){
view.setBackgroundResource(R.color.backgroundSelectedItem);
}