All Projects → nex3z → Togglebuttongroup

nex3z / Togglebuttongroup

Licence: apache-2.0
A group of flowable toggle buttons, with multiple / single selection support and button customization.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Togglebuttongroup

React Menu
React component for building accessible menu, dropdown, submenu, context menu and more.
Stars: ✭ 237 (-30.9%)
Mutual labels:  radio-buttons
Examples FLTK
Shows how to use Fltk controls only by programming code (c++17).
Stars: ✭ 28 (-91.84%)
Mutual labels:  radio-buttons
AMChoice
Radio Button and check box for iOS
Stars: ✭ 45 (-86.88%)
Mutual labels:  radio-buttons
Radiorealbutton
A custom radio button for Android API 12+
Stars: ✭ 250 (-27.11%)
Mutual labels:  radio-buttons
LC-switch
Superlight vanilla javascript plugin improving forms look and functionality
Stars: ✭ 31 (-90.96%)
Mutual labels:  radio-buttons
Examples Qt
Shows how to use Qt widgets only by programming code (c++17).
Stars: ✭ 38 (-88.92%)
Mutual labels:  radio-buttons
React Native Flexi Radio Button
Simple and flexible Radio button for React Native App
Stars: ✭ 151 (-55.98%)
Mutual labels:  radio-buttons
Examples Win32
Shows how to use Win32 controls by programming code (c++17).
Stars: ✭ 22 (-93.59%)
Mutual labels:  radio-buttons
CMB2-radio-image
Images as radio buttons
Stars: ✭ 18 (-94.75%)
Mutual labels:  radio-buttons
RadioGroup
支持多行多列等复杂布局的RadioGroup,重点是!!使用简单!!,称之为Multi_RadioGroup_Plus吧
Stars: ✭ 26 (-92.42%)
Mutual labels:  radio-buttons
Examples wxWidgets
Shows how to use wxWidgets controls only by programming code (c++17).
Stars: ✭ 116 (-66.18%)
Mutual labels:  radio-buttons
react-radios
🔘 Proper handling of HTML radios in react
Stars: ✭ 60 (-82.51%)
Mutual labels:  radio-buttons
react-native-radio-buttons-group
Simple, best and easy to use radio buttons for react native apps.
Stars: ✭ 145 (-57.73%)
Mutual labels:  radio-buttons
Pretty Checkbox Vue
Quickly integrate pretty checkbox components with Vue.js
Stars: ✭ 240 (-30.03%)
Mutual labels:  radio-buttons
Examples Gtkmm
Shows how to use Gtkmm controls by programming code (c++17).
Stars: ✭ 23 (-93.29%)
Mutual labels:  radio-buttons
Tristatetogglebutton
Customizable tri-state toggle button (with three states, three state toggle) for Android
Stars: ✭ 198 (-42.27%)
Mutual labels:  radio-buttons
pretty-checkbox-react
A tiny react/preact wrapper around pretty-checkbox
Stars: ✭ 35 (-89.8%)
Mutual labels:  radio-buttons
Lthradiobutton
A radio button with a pretty animation
Stars: ✭ 303 (-11.66%)
Mutual labels:  radio-buttons
homebridge-switcheroo
Simple on/off or multiswitch radio buttons for http reqs. Useful for lights, A/V systems, home automation, whatever
Stars: ✭ 38 (-88.92%)
Mutual labels:  radio-buttons
django-radiogrid
Django radio grid field
Stars: ✭ 28 (-91.84%)
Mutual labels:  radio-buttons

ToggleButtonGroup

API Android Arsenal

A container of toggle buttons, supports multiple / single selection and button customization.

Gradle

AndroidX:

dependencies {
    implementation 'com.nex3z:toggle-button-group:1.2.3'
}

AppCompact:

dependencies {
    implementation 'com.nex3z:toggle-button-group:1.1.9'
}

SingleSelectToggleGroup

You can create a group of single-select toggle buttons with SingleSelectToggleGroup.

<com.nex3z.togglebuttongroup.SingleSelectToggleGroup
    android:id="@+id/group_choices"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tbgCheckedButton="@+id/choice_a">

    <com.nex3z.togglebuttongroup.button.CircularToggle
        android:id="@+id/choice_a"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="A"/>

    <com.nex3z.togglebuttongroup.button.CircularToggle
        android:id="@+id/choice_b"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="B"/>

       <!--...-->

</com.nex3z.togglebuttongroup.SingleSelectToggleGroup>

MultiSelectToggleGroup

You can create a group of multi-select toggle buttons with MultiSelectToggleGroup.

<com.nex3z.togglebuttongroup.MultiSelectToggleGroup
    android:id="@+id/group_weekdays"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tbgChildSpacing="auto">

    <com.nex3z.togglebuttongroup.button.CircularToggle
        android:id="@+id/sun"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="S"/>

    <com.nex3z.togglebuttongroup.button.CircularToggle
        android:id="@+id/mon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="M"/>

    <!--...-->

</com.nex3z.togglebuttongroup.MultiSelectToggleGroup>

Flow Buttons to Next Row

<com.nex3z.togglebuttongroup.MultiSelectToggleGroup
    android:id="@+id/group_dummy"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    app:tbgFlow="true"
    app:tbgChildSpacing="auto"
    app:tbgChildSpacingForLastRow="align"
    app:tbgRowSpacing="8dp">

    <!--...-->

</com.nex3z.togglebuttongroup.MultiSelectToggleGroup>

With tbgFlow attribute set to true, buttons are allowed to flow to next row when there is no enough space in current row. With tbgChildSpacing set to auto, buttons are evenly placed in each row.

Listeners

For SingleSelectToggleGroup, use OnCheckedChangeListener to listen to the change of the checked button. Use getCheckedId() to get the id of the checked button.

SingleSelectToggleGroup single = (SingleSelectToggleGroup) findViewById(R.id.group_choices);
single.setOnCheckedChangeListener(new SingleSelectToggleGroup.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(SingleSelectToggleGroup group, int checkedId) {

    }
});

For MultiSelectToggleGroup, use OnCheckedStateChangeListener to be notified of any changes in the group. Use getCheckedIds() to get the ids of all checked buttons.

MultiSelectToggleGroup multi = (MultiSelectToggleGroup) findViewById(R.id.group_weekdays);
multi.setOnCheckedChangeListener(new MultiSelectToggleGroup.OnCheckedStateChangeListener() {
    @Override
    public void onCheckedStateChanged(MultiSelectToggleGroup group, int checkedId, boolean isChecked) {

    }
});

Custom Button

You can implement custom toggle button in three ways,

CompoundButton implements Checkable interface, toggles itself when being clicked and provides listener for ToggleButtonGroup to keep track of its checked state. CompoundButton is basically a Button / TextView. You can add your custom style and behaviour to the button like CustomCompoundButton from the sample.

If you choose to implement ToggleButton, besides the Checkable interface, you also need to implement a setOnCheckedChangeListener(), which allows ToggleButtonGroup to listen to the changes of any checked states. You need to handle the click event on the button and toggle its checked state properly, as ToggleButtonGroup will not toggle the button when it's being clicked. CustomToggleButton from the sample is a simple toggle button implementing ToggleButton.

CompoundToggleButton implements ToggleButton and toggles its checked state when being clicked. All you need to do is to design the look and feel for the checked and unchecked state. CustomCompoundToggleButton from the sample extends CompoundToggleButton and uses a flipping animation for state transition as shown above.

For more detail, please check the sample.

Licence

Copyright 2018 nex3z

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].