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

TextInputLayout in Sketchware

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

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation