Compound Button Group


Source link: https://github.com/llollox/CompoundButtonGroup

Compound Button Group Android

An Android library to easily implement compound buttons

Installation

Gradle

Add Gradle dependency:

dependencies {

compile 'com.llollox.androidprojects:compoundbuttongroup:1.0.2' 
}

Maven

<dependency>
<groupId>com.llollox.androidprojects</groupId>
<artifactId>compoundbuttongroup</artifactId>
<version>1.0.2</version>
<type>pom</type> </dependency>

Usage

Check Box

<com.llollox.androidprojects.compoundbuttongroup.CompoundButtonGroup
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:entries="@array/planets"
  app:compoundType="check_box"/>

Check Box Grid (2 Cols, Label After)

<com.llollox.androidprojects.compoundbuttongroup.CompoundButtonGroup
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:entries="@array/planets"
  app:compoundType="check_box"
  app:numCols="2"
  app:labelOrder="after"/>

Radio

<com.llollox.androidprojects.compoundbuttongroup.CompoundButtonGroup
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:entries="@array/planets"
  app:compoundType="radio"
  app:labelOrder="after"/>

Radio Grid (3 Cols)

<com.llollox.androidprojects.compoundbuttongroup.CompoundButtonGroup
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:entries="@array/planets"
  app:compoundType="radio"
  app:numCols="3"
  app:labelOrder="after"/>

Getters

  • List<Integer> getCheckedPositions() Returns the current checked positions
List<Integer> positions = compoundButtonGroup.getCheckedPositions();
  • CompoundType getCompoundType() Get the type of the compound buttons.
compoundButtonGroup.getCompoundType();
  • LabelOrder getLabelOrder() Get the label order of the compound buttons. This determines if the label is before or after the compound button.
compoundButtonGroup.getLabelOrder();
  • int getNumCols() Get the current number of cols.
compoundButtonGroup.getNumCols();

Setters

  • void setCheckedPosition(int position) Checks the button at the position passed as argument. Typically to be used with radio buttons.
int position = 3; compoundButtonGroup.setCheckedPosition(position);
  • void setCheckedPositions(List<Integer> positions) Checks all the buttons at the positions passed as argument. Typically to be used with check box buttons.
List<Integer> positions = new ArrayList<Integer>(){
{
add(2);
 add(4);

}

}
; compoundButtonGroup.setCheckedPositions(positions);
  • void setCompoundType(CompoundType compoundType) Set the type of the compound buttons. Allowed values are: CompoundType.CHECK_BOX, CompoundType.RADIO. In order to see the changes on UI please call the reDraw() method.
compoundButtonGroup.setCompoundType(CompoundButtonGroup.CompoundType.RADIO);
  • void setEntries(List<String> entries) Set the entries for the compound button group. In order to see the changes on UI please call the reDraw() method.
List<String> entries = new ArrayList<String>(){
{
add("Mars");
 add("Mercury");
 add("Earth");

}

}
; compoundButtonGroup.setEntries(entries);
  • void setEntries(HashMap<String, String> entries) Set the entries for the compound button group. The key / value pair represent the value / label of the entry respectively. In order to see the changes on UI please call the reDraw() method.
LinkedHashMap<String, String> map = new LinkedHashMap<>();
 map.put("house", getString(R.string.house));
 map.put("orange", getString(R.string.orange));
 compoundButtonGroup.setEntries(map);
 compoundButtonGroup.reDraw();
  • void setLabelOrder(LabelOrder LabelOrder) Set the label order of each compound button. This determines if the label is before or after the compound button. Allowed values are: LabelOrder.BEFORE, LabelOrder.AFTER. In order to see the changes on UI please call the reDraw() method.
compoundButtonGroup.setLabelOrder(CompoundButtonGroup.LabelOrder.AFTER);
  • void setNumCols(int numCols) Set the number of cols. If it is greater than 1 the compound buttons are shown as a grid. NB. It cannot be smaller than 1! In order to see the changes on UI please call the reDraw() method.
int numCols = 2; compoundButtonGroup.setNumCols(numCols);

Listeners

OnButtonSelectedListener
compoundButtonGroup.setOnButtonSelectedListener(new CompoundButtonGroup.OnButtonSelectedListener() {

  @Override
  public void onButtonSelected(int position, String value, boolean isChecked) {

// Your code
  
}
 
}
);

Attributes

It is possible to customize the compound button group applying the following options:

Option Name Format Description
w app:compoundType check_box or radio
app:entries array String array of the entries of the compound button group.
app:labelOrder before or after This determines if the label is before or after the compound button. By default is before.
app:numCols int Setting this parameter the compound buttons are shown as a grid and it indicates the number of cols of the grid.

Resources

A morphing toolbar that can expand/collapse at anytime.

An Android TagView library. You can customize awesome TagView by using this library.

This is the Android port of an NES emulator written in Go.

Android Library that shows a beautiful and customizable Material designed dialog with header.

An Intellij platform plugin to transforming SVG to android VectorDrawable.

The ultimate product information API, enabling a new breed of product-centric apps.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes