Clicking on item programmatically in RecyclerView

后端 未结 4 888
闹比i
闹比i 2020-12-14 16:03

I am loading a list of categories and depending on which is selected, I need to show the products of the corresponding category in the RecyclerView. So when I f

4条回答
  •  借酒劲吻你
    2020-12-14 16:39

    Here is a workaround to select 1st child of RecyclerView after just setting adapter.

    //position to be clicked
    final int pos = 0;
    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
    recyclerView.findViewHolderForAdapterPosition(pos).itemView.performClick();
                        }
                    },1);
    

提交回复
热议问题