How to get view from RecyclerView at specific adapter position and get values from those views?

前端 未结 1 600
栀梦
栀梦 2021-01-05 19:32

I have RecyclerView having an ImageView and a TextView for each row layout.In ViewHolder in RecyclerViewAdapter, I have click listener as

 v.setOnClickList         


        
相关标签:
1条回答
  • 2021-01-05 19:43

    Try this use recyclerView.getLayoutManager().findViewByPosition(int position) to get particular row of recyclerView

    View row = recyclerView.getLayoutManager().findViewByPosition(0);
    TextView textView = row.findViewById(R.id.YourTextviwID);
    textView.setText("Nilu");
    ImageView textView = row.findViewById(R.id.YourImageViewID);
    imageView.setBackgroundResource(R.mipmap.ic_launcher);
    

    NOTE :- only item that is display in screen when you scroll recyclerView than item will removed from memory

    EDIT :- you can write a public method in adapter to get your arraylist in your activity where you can check your flag

    0 讨论(0)
提交回复
热议问题