Multi Line Radio Group is a Radio Group layout to show radio buttons in more than one line.

Overview

MultiLineRadioGroup

Multi Line Radio Group is a Radio Group layout to show radio buttons in more than one line.

Setup

In your project's build.gradle file:

allprojects {
    repositories {
        ...
        maven { 
            url "https://jitpack.io"
        }
        ...
    }
}

In your Application's or Module's build.gradle file:

dependencies {
    ...
    compile 'com.github.Gavras:MultiLineRadioGroup:v1.0.0.6'
    ...
}

XML Attributes:

XML Attributes:

max_in_row: A non-negative number that represents the maximum radio buttons in a row, 0 for all in one line.

radio_buttons: String-array resource reference that represents the texts of the desired radio buttons.

default_button: String that represents the text or the index of the radio button to be checked by default. The string should be in the following format: for text: "text:[text-of-button]" where text-of-button is the text of the button to check. for index: "index:[index-of-button]" where index-of-button is the index of the button to check. when the prefix omitted, "text:" inserted implicitly.

Code Example

From XML:

<com.whygraphics.multilineradiogroup.MultiLineRadioGroup xmlns:multi_line_radio_group="http://schemas.android.com/apk/res-auto"
        android:id="@+id/main_activity_multi_line_radio_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        multi_line_radio_group:default_button="button_2"
        multi_line_radio_group:max_in_row="3"
        multi_line_radio_group:radio_buttons="@array/radio_buttons" />

and in arrays.xml:

<string-array name="radio_buttons">
        <item>button_1</item>
        <item>button_2</item>
        <item>button_3</item>
        <item>button_4</item>
        <item>button_5</item>
</string-array>

In the activity:

MultiLineRadioGroup mMultiLineRadioGroup = (MultiLineRadioGroup) findViewById(R.id.main_activity_multi_line_radio_group);

mMultiLineRadioGroup.setOnCheckedChangeListener(new MultiLineRadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(ViewGroup group, RadioButton button) {
                Toast.makeText(MainActivity.this,
                        button.getText() + " was clicked",
                        Toast.LENGTH_SHORT).show();
            }
});

Adding radio buttons programmatically:

mMultiLineRadioGroup.addButtons("button to add 1", "button to add 2", "button to add 3");
Comments
  • allow removeAll to be a no-opp if there are no radio buttons

    allow removeAll to be a no-opp if there are no radio buttons

    When adding radio buttons programmatically, we need to always reset to a known empty state. Rather than make all clients check if the RadioGroup has buttons this allows the removeAllButtons() to be a no-opp.

    backfill tests.

    opened by jwmach1 3
  • error icon launcher

    error icon launcher

    the icon launcher from the multilineradiogroup was replace the icon_launcher from project, so ai create the new icon launcher and changed name new icon , but i get error like bellow . please help.

    Error:Execution failed for task ':app:processDebugManifest'.

    Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher_psks) from AndroidManifest.xml:15:9-48 is also present at [com.github.Gavras:MultiLineRadioGroup:v1.0.0.4] AndroidManifest.xml:13:9-43 value=(@mipmap/ic_launcher). Suggestion: add 'tools:replace="android:icon"' to element at AndroidManifest.xml:13:5-49:19 to override.

    opened by winzaldi 2
  • OnCheckedChange is called for all clicks, not just changes.

    OnCheckedChange is called for all clicks, not just changes.

    with an interface method that is named the same as the parent class, the behaviour should be the same -- clicking the same radioButton should not emit a new 'onCheckChange' event since the check state did not change when the same radio button is clicked. Tests show this is the behavior of the base RadioGroup class.

    While the listener interface is different, it has the same name as the base class. While this might be the object oriented design principle that is good to follow -- don't change behavior of a base method. There is a functional implication. Clients of the library that execute functionality upon check change would only expect/want that functionality to execute once -- when the radio gets checked.

    opened by jwmach1 2
  • How can i set checked in particular radio button programmatically ?

    How can i set checked in particular radio button programmatically ?

    I have created a radio group with more than 6 radio button how can I set checked the 3 rd radio button in this group SELECT and DESELECT ( setchecked = true, setchecked = false) in programmatically?

    opened by imramsuthakar 0
  • update restore instance state to avoid 'wrong state class' exception.

    update restore instance state to avoid 'wrong state class' exception.

    The current implementation of onRestoreInstanceState causes the following exception. By checking the type of the saved state we avoid this problem and use the superState when necessary. I loosely followed the example from Tricky Android keeping the if condition you started with (as I've done on other custom controls)

    Wrong state class, expecting View State but received class com.whygraphics.multilineradiogroup.MultiLineRadioGroup$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is NO_ID. Make sure other views do not use the same id

    opened by jwmach1 0
  • PerformClick(); issue

    PerformClick(); issue

    Hello ,, I Think this peace of code

    public void checkAt(int index) {
        if(index >= 0 && index < this.mRadioButtons.size()) {
            this.checkButton((RadioButton)this.mRadioButtons.get(index));
        }
    }
    
    private void checkButton(RadioButton button) {
        if(button != null) {
            if(button != this.mCheckedButton) {
                if(this.mCheckedButton != null) {
                    this.mCheckedButton.setChecked(false);
                }
    
                button.setChecked(true);
                this.mCheckedButton = button;
            }
    
        }
    }
    

    not called "mOnCheckedChangeListener" i think after define 'mCheckedButton' just call 'button.performClick();' this will call the listener. to be like that -->

    public void checkAt(int index) {
        if(index >= 0 && index < this.mRadioButtons.size()) {
            this.checkButton((RadioButton)this.mRadioButtons.get(index));
        }
    }
    
    private void checkButton(RadioButton button) {
        if(button != null) {
            if(button != this.mCheckedButton) {
                if(this.mCheckedButton != null) {
                    this.mCheckedButton.setChecked(false);
                }
    
                button.setChecked(true);
                this.mCheckedButton = button;
                button.performClick();
            }
    
        }
    }
    

    i hope updating this peace of code. Thanks ,,,, @Gavras

    opened by dev-hussein 4
Releases(v1.0.0.6)
  • v1.0.0.6(Dec 12, 2017)

  • v1.0.0.5.2(Dec 11, 2017)

  • v1.0.0.4(Jul 24, 2017)

    • add setOnClickListener with a custom interface from the base RadioGroup to be notified upon each click. This is distinct from the onCheckChangeListener that is only called for check state changes. This is needed because the control will hijack the onClickListener set upon any added child RadioButton.
    • Bug fix in clearCheck that would crash if there was no button checked.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0.3(Jul 21, 2017)

    • removeAll method is now a no-op when there are no buttons instead of throwing IllegalArgumentException
    • OnCheckedChangeListener will only be called when the check changes (instead of every click)
    • fix bug in onRestoreInstanceState that would cause a crash on some devices upon config change
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0.2(Jan 12, 2017)

  • v1.0.0.1(Jan 9, 2017)

  • 1.0(Jan 2, 2017)

Owner
Tzlil Gavra
https://www.linkedin.com/in/tzlil-gavra-973663127/
Tzlil Gavra
Binding your extras more easier, more simpler for your Android project

Ktan Ktan make your intent / arguments more easier and readable. And most important, will help you bind all extras for your activity / fragment. And a

Ade Fruandta 3 Jan 7, 2023
One app for all women that covers everything from safety to health and more. 👩💪

sampoorna Sampoorna is a one-in-all solution concept revolving around the women who fight one on one with various problems. With it's features encapsu

Open Lake 17 Dec 6, 2022
An Online Meme Sharing app with swipeable vidoes, user can like, share different videos, each viewpager item has one video to show.

MemesSharing An Online Meme Sharing app with swipeable vidoes, user can like, share different videos, each viewpager item has one video to show. 1. Fl

Vikas Bajpayee 13 Aug 6, 2022
An open-source Android app for locating your group's people privately using Facebook Login, Google Maps API and Firebase

An open-source Android app for locating your group's people privately using Facebook Login, Google Maps API and Firebase

Duong Tran Thanh 2 Feb 27, 2022
HackerNews with Kotlin Multi-platform mobile technology

KNews The goal of this project is to build mobile apps that consumes HackerNews API with Kotlin Multi-Platform technology. About My idea is to build 2

Kittinun Vantasin 43 Oct 3, 2022
Android Multi Theme Switch Library ,use kotlin language ,coroutine ,and so on ...

Magic Mistletoe Android多主题(换肤)切换框架 背景 时隔四年,在网易换肤之前的思路下,做了几点改进,现在完全通过反射创建View,并且在SkinLoadManager中提供一个configCustomAttrs以支持自定义View的属性插队替换 摈弃了之前的AsyncTask

Mistletoe 18 Jun 17, 2022
Kotlin Multi Platform UI

Xeon UI (work-in-progress ?? ??️ ??‍♀️ ⛏ ) Development Version Release This Is Latest Release ~ In Development $version_release = ~ What's New?? * In

Frogobox 2 Oct 15, 2021
Multi-thread ZX0 data compressor in Kotlin

ZX0-Kotlin ZX0-Kotlin is a multi-thread implementation of the ZX0 data compressor in Kotlin. Requirements To run this compressor, you must have instal

Einar Saukas 2 Apr 14, 2022
For Kotlin with SpringBoot project that have multi-module-structure template

Goals kotlin + spring-boot + gradle + multi-module building Module-Structure ---root |--- src.main.kotlin.KotlinSpringbootMultiModuleTemplateAppl

pguma 1 Jul 24, 2022
A deep learning based mobile application for the multi-class classification of pneumonia into three categories via Chest X-rays

PneumoniaClassifier A deep learning based mobile application for the multi-class classification of pneumonia into three categories via Chest X-rays. W

Timilehin Aregbesola 2 Dec 15, 2021
Kotlin multi-platform application navigation library.

navigation Kotlin multi-platform application navigation library. Supports Jetpack Compose. val navigator = rememberNavigatorByKey("Greeting") { key ->

Christopher 9 Jan 2, 2023
Muhammad Valian Masdani 2 Jul 5, 2022
Kotlin multi-platform simple File I/O library

KmpIO This is a Kotlin multiplatform (KMP) library for basic Text file, Binary file, and zip/archive file IO. It was initially implemented with the an

Steven K Olson 9 Oct 1, 2022
A Gradle plugin providing various utility methods and common code required to set up multi-version Minecraft mods.

Essential Gradle Toolkit A Gradle plugin providing various utility methods and common code required to set up multi-version Minecraft mods via archite

Essential 29 Nov 1, 2022
A complete Kotlin application built to demonstrate the use of Modern development tools with best practices implementation using multi-module architecture developed using SOLID principles

This repository serves as template and demo for building android applications for scale. It is suited for large teams where individuals can work independently on feature wise and layer wise reducing the dependency on each other.

Devrath 11 Oct 21, 2022
Clean Android multi-module offline-first scalable app in 2022. Including Jetpack Compose, MVI, Kotlin coroutines/Flow, Kotlin serialization, Hilt and Room.

Android Kotlin starter project - 2022 edition Android starter project, described precisely in this article. Purpose To show good practices using Kotli

Krzysztof Dąbrowski 176 Jan 3, 2023
Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI

KMMNewsAPP There are two branches Main News App Main The main branch is a complete template that you can clone and use to build the awesome app that y

Kashif Mehmood 188 Dec 30, 2022
Plugin and Desktop app for parsing layout xml into Composable code

composed-xml Inspired by - Recompose composed-xml is a tool for parsing Android layouts into Jetpack Compose code. It can work as both Desktop app or

Bacho Kurtanidze 9 Dec 26, 2022
Android Kotlin Fundamentals codelab(Lesson 2: Layouts(Constraints Layout))

ColorsMyView Finished code for Android Kotlin Fundamentals codelab(Lesson 2: Layouts(Constraints Layout)) Introduction The ColorMyViews app is inspire

Animesh Roy 0 Nov 26, 2021