Answers for "android kotlin radio group"

0

android studio radio group horizontal

<RadioGroup
   android:id="@+id/radioG"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content" 
   android:orientation='horizontal'>
Posted by: Guest on January-04-2021
0

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");
Posted by: Guest on October-07-2020
0

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
                }
        }
    }
}
Posted by: Guest on September-25-2021
0

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()

    }
Posted by: Guest on September-25-2021

Browse Popular Code Answers by Language