Advertisement
retnet

onclick change background listview or recyclerview

Sep 5th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public int row_index = -1;
  2. @Override
  3. public void onBindViewHolder.........
  4. ........
  5.  
  6. holder.linieriven.setOnClickListener(new View.OnClickListener() {
  7. @Override
  8. public void onClick(View view) {
  9. row_index=position;
  10. notifyDataSetChanged();
  11. ....................................
  12. .................
  13. }
  14. });
  15. if(row_index==position){
  16. holder.linieriven.setBackgroundColor(Color.parseColor("#675B77"));
  17. }
  18. else {
  19. holder.linieriven.setBackgroundColor(Color.parseColor("#483A5C"));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement