How to change particular image in recycler view after clicking

前端 未结 4 1975
别那么骄傲
别那么骄傲 2021-02-03 16:04

I want to change respective image of clicked item in recycler view. Now whats happening is if i click on item 2 image is changing at random item position in the list

<         


        
4条回答
  •  天涯浪人
    2021-02-03 16:36

    Try this:

     @Override 
    public void onBindViewHolder(MyRecyclerViewAdapter.DataObjectHolder holder,int position {
    
    holder.name.setText(mDataset.get(position).getName());
    holder.regId.setText(mDataset.get(position).getRegId());
    holder.roomNo.setText(mDataset.get(position).getRoomNo());
    holder.testImage = (ImageView)itemView.findViewById(R.id.log)
    holder.testImage.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v) {
             name.setImageResource(Anything you want);
    
    
    }
    

提交回复
热议问题