Widget - RadioButton

//Horizontal


final RadioButton[] rb = new RadioButton[5];
final RadioButton[] gg = new RadioButton[5];
    RadioGroup rg = new RadioGroup(this);

//create the RadioGroup
    rg.setOrientation(RadioGroup.HORIZONTAL);
    for(int i=0; i<1; i++){
       rb[i]  = new RadioButton(this);         
       rb[i].setText("Correct!");
       rb[i].setId(1);
 gg[i]  = new RadioButton(this);         
       gg[i].setText("Wrong!");
       gg[i].setId(2);

       rg.addView(rb[i]);
rg.addView(gg[i]);
linear1.addView(rg);
}


// Vertical

final RadioButton[] rb = new RadioButton[5];
final RadioButton[] gg = new RadioButton[5];
    RadioGroup rg = new RadioGroup(this);

//create the RadioGroup
    rg.setOrientation(RadioGroup.VERTICAL);
    for(int i=0; i<1; i++){
       rb[i]  = new RadioButton(this);         
       rb[i].setText("Correct!");
       rb[i].setId(1);
 gg[i]  = new RadioButton(this);         
       gg[i].setText("Wrong!");
       gg[i].setId(2);

       rg.addView(rb[i]);
rg.addView(gg[i]);
linear1.addView(rg);
}

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key