VTR2015 VTR2015 -4 years ago 153
Android Question

Programmatically make a click or touch an item in recyclerview

How to force a click or touch an item on a recyclerview?

I found people talking to use a command

recyclerView.findViewHolderForAdapterPosition(0).itemView.performClick()
but
recyclerView.findViewHolderForAdapterPosition(0)
always returns null!

I want initially that the first recyclerview item is clicked/ touched.

Answer Source
  new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
              recyclerView.findViewHolderForAdapterPosition(position).itemView.performClick();

            }
        },100);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download