RadioButton r = (RadioButton) radioButton .getChildAt(idx); String selectedtext = r.getText().toString();
if(rg1.getCheckedRadioButtonId()!=-1){ int id= rg1.getCheckedRadioButtonId(); View radioButton = rg1.findViewById(id); int radioId = radioGroup.indexOfChild(radioButton); RadioButton btn = (RadioButton) rg1.getChildAt(radioId); String selection = (String) btn.getText(); }
// This overrides the radiogroup onCheckListener rGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { // This will get the radiobutton that has changed in its check state RadioButton checkedRadioButton = (RadioButton)group.findViewById(checkedId); // This puts the value (true/false) into the variable boolean isChecked = checkedRadioButton.isChecked(); // If the radiobutton that has changed in check state is now checked... if (isChecked) { // Changes the textview's text to "Checked: example radiobutton text" tv.setText("Checked:" + checkedRadioButton.getText()); } } });
radioButton.getText(), Toast.LENGTH_SHORT).show();
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { // checkedId is the RadioButton selected RadioButton rb=(RadioButton)findViewById(checkedId); textViewChoice.setText("You Selected "+rb.getText()); //Toast.makeText(getApplicationContext(), rb.getText(), Toast.LENGTH_SHORT).show(); } });
radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { void onCheckedChanged(RadioGroup rg, int checkedId) { for(int i=0; i<rg.getChildCount(); i++) { RadioButton btn = (RadioButton) rg.getChildAt(i); if(btn.getId() == checkedId) { String text = btn.getText(); // do something with text return; } } } });
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int childCount = group.getChildCount(); for (int x = 0; x < childCount; x++) { RadioButton btn = (RadioButton) group.getChildAt(x); if (btn.getId() == checkedId) { Log.e("selected RadioButton->",btn.getText().toString()); } } } });
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radiogroup); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton checkedRadioButton = (RadioButton) findViewById(checkedId); String text = checkedRadioButton.getText().toString(); Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } });
headerColorToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed( ObservableValue<? extends Toggle> observableValue, Toggle oldToggle, Toggle newToggle ) { RadioButton radio = (RadioButton) newToggle; header.setStyle("header-base-color: " + radio.getText()); } });
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { // checkedId is the RadioButton selected RadioButton rb=(RadioButton)findViewById(checkedId); Toast.makeText(getApplicationContext(), rb.getText(), Toast.LENGTH_SHORT).show(); } });
radioGroup1.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton radioButton = (RadioButton) findViewById(checkedId); Toast.makeText(Location.this, "" + radioButton.getText(), 2000).show(); } });
bSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Id of checked radio button int checkedId = rgroup.getCheckedRadioButtonId(); //Text of that id if(checkedId > 0) { //condition to check that at radio button is selected. RadioButton radioButton = (RadioButton) findViewById(checkedId); String text = radioButton.getText().toString(); } } });
btnDisplay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { RadioButton selectedButton= (RadioButton)findViewById(radioGroup.getCheckedRadioButtonId()); //you will get the selected radiobutton here String s=selectedButton..getText().toString(); Toast.makeText(Radio_Button.this, "This is: " + s,Toast.LENGTH_LONG).show(); }
myGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> ov, Toggle t, Toggle t1) { RadioButton chk = (RadioButton)t1.getToggleGroup().getSelectedToggle(); // Cast object to radio button System.out.println("Selected Radio Button - "+chk.getText()); } });
RadioGroup g = (RadioGroup) findViewById(R.id.rBtnDigits); // Returns an integer which represents the selected radio button's ID int selected = g.getCheckedRadioButtonId(); // Gets a reference to our "selected" radio button RadioButton b = (RadioButton) findViewById(selected); // Now you can get the text or whatever you want from the "selected" radio button b.getText();
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub int childCount = group.getChildCount(); for (int x = 0; x < childCount; x++) { RadioButton btn = (RadioButton) group.getChildAt(x); if (btn.getId() == checkedId) { System.out.println(btn.getText().toString()); } } });
int childCount=group.getChildCount(); for (int i=0;i<childCount;i++){ if(group.getChildAt(i) instanceof RadioButton ) { // check if child is `RadioButton` RadioButton r_btn = (RadioButton) group.getChildAt(i); if (r_btn.getId() == checkedId) { System.out.println(r_btn.getText().toString()); } } }
OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { RadioButton rb = (RadioButton) v; Toast.makeText(your_Activity.this, rb.getText(), Toast.LENGTH_SHORT).show(); } }; RadioButton rb1 = (RadioButton) findViewById(R.id.radioButton1); rb1.setOnClickListener(listener);
public void onRadioButtonClick(View v) { RadioButton rb = (RadioButton) v; Toast.makeText(getApplicationContext(), rb.getText(),Toast.LENGTH_SHORT).show(); View Rg = (View) rb.getParent(); View LLayout = (View) Rg.getParent(); TextView txtLvId = (TextView) LLayout.findViewById(R.id.ins_itemid); String LvID = txtLvId.getText().toString(); Toast.makeText(getApplicationContext(), LvID, Toast.LENGTH_LONG).show(); }
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton radioButton = (RadioButton) group.findViewById(checkedId); if(radioButton.getText().equals("yes")) { radioButton.setBackgroundColor(Color.GREEN); } else { radioButton.setBackgroundColor(Color.RED); } } });