changing background color of selected item in recyclerview

Solutions on MaxInterview for changing background color of selected item in recyclerview by the best coders in the world

showing results for - "changing background color of selected item in recyclerview"
Evita
31 Feb 2020
1public void onBindViewHolder(final ViewHolder holder, final int position) {
2        holder.tv1.setText(android_versionnames[position]);
3
4        holder.row_linearlayout.setOnClickListener(new View.OnClickListener() {
5            @Override
6            public void onClick(View view) {
7                row_index=position;
8                notifyDataSetChanged();
9            }
10        });
11        if(row_index==position){
12            holder.row_linearlayout.setBackgroundColor(Color.parseColor("#567845"));
13            holder.tv1.setTextColor(Color.parseColor("#ffffff"));
14        }
15        else
16        {
17            holder.row_linearlayout.setBackgroundColor(Color.parseColor("#ffffff"));
18            holder.tv1.setTextColor(Color.parseColor("#000000"));
19        }
20
21    }
22
queries leading to this page
on recyclear view item click background color change android programmaticallylistview change item background colorhow to change background color of selected item in recyclerview in androidhow to change background color on click in recyclerview androidmy recycler view change background colorhow to change color of selected item in recyclerviewitem in recyclerview showing background colorrecyclerview item color change backgroundcolor tint programmaticallychange background color of recyclerview set background color of recyclerview androidchange recyclerview background colorchange recyclerview item background color on clickandroid single selected item color change in recyclear viewhow to change background color in recyclerview in androidandroid recyclerview change background color selected itemhow to change recyclerview selected item background color in androidset background color for only currently clicked item in recycler view listchange background color of recyclerview itemhow to change the background color of selected item in recyclerviewviewholder itemview setbackgroundhow to change recyclerview selected item background color in kotlinset item text color is selected item in recyclerviewhow to change on click specific background color on recyclerview androidrecyclerview item color change backgroundtintcolor programmaticallyandroid recyclerview change background color selected item programmaticallyrecyclerview item color change backgroundtintcolot programmaticallyrecyclerview change background color on clickstet text color is selected item in recyclerviewchanging background color of selected item in recyclerviewhow to set background color in recyclerview dynamicallychanging background color of selected item in recyclerview