Material Button Toggle Group single selection

前端 未结 4 2004
抹茶落季
抹茶落季 2021-02-19 04:55

How can I force a MaterialButtonToggleGroup to act like a RadioGroup as in having at least one selected item always? Setting setSingleSelection(true)

4条回答
  •  再見小時候
    2021-02-19 05:51

    Now you can achieve it using the app:selectionRequired attribute.
    Something like:

        
    

    Also you can programmatically use the method setSelectionRequired:

    buttonGroup.setSelectionRequired(true);
    

    Please note that this attribute requires a minimum of version 1.2.0-alpha03

提交回复
热议问题