How to disable RecyclerView Items from clicking

后端 未结 9 903
迷失自我
迷失自我 2020-12-31 04:00

I am using Floating Action Button. I want to disable Recyclerview Items from Clicking when i press FAB button. I tried this method but not working setClickable(true);<

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 04:43

    You can add a simple boolean to your adapter like this:

    public boolean isClickable = true;
    

    and set it in your fab-click:

    mAdapter.isClickable = true/false;
    

    And within your OnClickListener in the Adapter, only act when it is clickable:

    public void onClick(View view) {
        if(!isClickable)
            return;
        // do your click stuff
    }
    

提交回复
热议问题