search

Home  >  Q&A  >  body text

android - Question about checkbox in recyclerView.

As shown in the picture, click on the time of today’s checkbox. How to make all checkboxes selected? Please provide me with ideas

曾经蜡笔没有小新曾经蜡笔没有小新2691 days ago1624

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-07-06 10:38:18

    Xie Yao.

    1. Listen to checkbox events, copy, and operate sub-checkboxes

    2. Customized checkbox component. I wrote it myself and operate it however I want.

    CheckBox repeatChkBx = ( CheckBox ) findViewById( R.id.repeat_checkbox );
    repeatChkBx.setOnCheckedChangeListener(new OnCheckedChangeListener()
    {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
        {
            if ( isChecked )
            {
                // perform logic
            }
    
        }
    });

    reply
    0
  • 滿天的星座

    滿天的星座2017-07-06 10:38:18

    Using CheckBox in RecyclerView will cause the reuse problem of ViewHolder. The reused CheckBox after sliding will inherit the previous state.

    It is recommended to modify the selected state in the bound data entity instead of directly modifying the selected state of CheckBox. At the same time, in bindData, only control the state of CheckBox based on the selected state of the data.

    Please ask, is this implemented by two layers of RecyclerView, ItemDecoration or different ViewTypes?

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-07-06 10:38:18

    I’ll give you a wheel, it’s actually very simple. Address: https://github.com/JerryMissT...

    reply
    0
  • Cancelreply