android studio radio group horizontal
<RadioGroup
android:id="@+id/radioG"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation='horizontal'>
android studio radio group horizontal
<RadioGroup
android:id="@+id/radioG"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation='horizontal'>
android iterate through radio group java
int count = radioGroup.getChildCount();
ArrayList<RadioButton> listOfRadioButtons = new ArrayList<RadioButton>();
for (int i=0;i<count;i++) {
View o = radioGroup.getChildAt(i);
if (o instanceof RadioButton) {
listOfRadioButtons.add((RadioButton)o);
}
}
Log.d(TAG,"you have "+listOfRadioButtons.size()+" radio buttons");
android kotlin radio group
fun onRadioButtonClicked(view: View) {
if (view is RadioButton) {
// Is the button now checked?
val checked = view.isChecked
// Check which radio button was clicked
when (view.getId()) {
R.id.radio_pirates ->
if (checked) {
// Pirates are the best
}
R.id.radio_ninjas ->
if (checked) {
// Ninjas rule
}
}
}
}
android kotlin radio group
fun calcular(v: View) {
var val1 = findViewById<EditText>(R.id.txtV1).text.toString().toFloat()
var val2 = findViewById<EditText>(R.id.txtV2).text.toString().toFloat()
var op = findViewById<RadioGroup>(R.id.operacoes).checkedRadioButtonId;
var result = 0f;
if(op.equals(R.id.rbSomar)){
result = val1 + val2
}
if(op.equals(R.id.rbSubt)){
result = val1 - val2
}
if(op.equals(R.id.rbMult)){
result = val1 * val2
}
if(op.equals(R.id.rbDivd)){
result = val1 / val2
}
findViewById<TextView>(R.id.txtRes).text = result.toString()
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us