# CompoundButtonGroup
**Repository Path**: HarmonyOS-tpc/CompoundButtonGroup
## Basic Information
- **Project Name**: CompoundButtonGroup
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-09-17
- **Last Updated**: 2023-04-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Compound Button Group
An openharmony library to easily implement compound buttons
## Usage Instructions
XML
Check Box Grid (2 Cols, Label After)
Radio
Radio Grid (3 Cols)
Java
### Getters
Returns the current checked positions
List positions = compoundButtonGroup.getCheckedPositions();
Get the type of the compound buttons.
compoundButtonGroup.getCompoundType()
Get the label order of the compound buttons. This determines if the label is before or after the compound button.
compoundButtonGroup.getLabelOrder();
Get the current number of cols.
compoundButtonGroup.getNumCols();
### Setters
Checks the button at the position passed as argument. Typically to be used with radio buttons.
int position = 3;
compoundButtonGroup.setCheckedPosition(position);
Checks all the buttons at the positions passed as argument. Typically to be used with check box buttons.
List positions = new ArrayList(){{add(2); add(4);}};
compoundButtonGroup.setCheckedPositions(positions);
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);
Set the entries for the compound button group. In order to see the changes on UI please call the reDraw() method.
List entries = new ArrayList(){{add("Mars"); add("Mercury"); add("Earth");}};
compoundButtonGroup.setEntries(entries);
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);
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
compoundButtonGroup.setOnButtonSelectedListener(new CompoundButtonGroup.OnButtonSelectedListener() {
@Override
public void onButtonSelected(int position, String value, boolean isChecked) {
// Your code
}
});
## Installation Instructions
1. For using CompoundButtonGroup module in sample app,include the below library jar/har in libs folder of "compoundbuttongroup" module to generate hap/compoundbuttongroup.har:
Modify entry build.gradle as below :
```
dependencies {
implementation project(':compoundbuttongroup')
testImplementation 'junit:junit:4.13'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}
```
2. For using CompoundButtonGroup in separate application make sure to add the below dependent libraries in entry libs folder along with the main compoundbuttongroup.har :
Modify entry build.gradle as below :
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
testImplementation 'junit:junit:4.13'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}
```
3.For using CompoundButtonGroup from a remote repository in separate application, add the below dependency in entry/build.gradle file.
Modify entry build.gradle as below :
```gradle
dependencies {
implementation 'io.openharmony.tpc.thirdlib:CompoundButtonGroup:1.0.0'
}
```