#StackBounty: #android #android-recyclerview #recycler-adapter #android-viewholder How to detect each RecyclerView item after it is dis…

Bounty: 150

I want to detect each item in my RecylerView after it is displayed to the user.

Basically, I am trying to play a sound on each item after it is loaded on the screen.
But I am not able to detect whenever each item is loaded on the screen! Is there any method I have to call to detect each item rendered

E.g 1st RecyclerView item displayed -> play sound
    2st RecyclerView item displayed -> play sound...

My Adapter class looks like this –

public class AdapterListAnimation extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<Multiples> items = new ArrayList<>();

    private Context ctx;
    private OnItemClickListener mOnItemClickListener;
    private int animation_type = 0;

I am calling this init component() method from onCreated() method, can you able to give advice on what should i do to achieve my goal as described above

 private void initComponent() {
        recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        items = DataGenerator.getPeopleData(this,of,value);
       /* MediaPlayer mp=MediaPlayer.create(this, R.raw.sword);
        if (mp.isPlaying()) {
            mp = MediaPlayer.create(this, R.raw.sword);
        } mp.start();*/


    private void setAdapter() {
        //set data and list adapter
        mAdapter = new AdapterListAnimation(this, items, animation_type);

        // on item list clicked
        mAdapter.setOnItemClickListener(new AdapterListAnimation.OnItemClickListener() {
            public void onItemClick(View view, com.math.multiplication.model.Multiples obj, int position) {
                Snackbar.make(parent_view, "Item " + obj.first + " clicked", Snackbar.LENGTH_SHORT).show();

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.