Refine search
int selectedId = radioGroup.getCheckedRadioButtonId(); radioButton.getText(), Toast.LENGTH_SHORT).show();
// 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()); } } });
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; } } } });
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { RadioGroup rChoi=(RadioGroup) findViewById(R.id.radiogroupchoi); RadioButton butChoi=rChoi.findViewById(rChoi.getCheckedRadioButtonId()); Toast.makeText(getApplicationContext(),butChoi.getText(), Toast.LENGTH_SHORT).show(); } });
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); RadioGroup rg1 = (RadioGroup) view.findViewById(R.id.radioGroup1); rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged (RadioGroup group,int checkedId){ Context context = getContext(); RadioButton thisButton = (RadioButton) getView().findViewById(checkedId); Toast toast = Toast.makeText(context, thisButton.getText(), Toast.LENGTH_SHORT); toast.show(); } } ); }
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub int rbId = group.getCheckedRadioButtonId(); RadioButton rb = (RadioButton) findViewById(rbId); switch (group.getId()) { case R.id.radiogroupID: if (rb.getText().toString().equalsIgnoreCase("right")) { // your logic } else { //your logic } } }
final RadioGroup status_group = (RadioGroup) findViewById(R.id.status_group); //-- By default if you want open button to be checked, you can do that by using status_group.check(R.id.open_radio); status_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton radioButton = (RadioButton) findViewById(checkedId); status_group.check(checkedId); radio_status = radioButton.getText().toString().trim(); Log.v("radio_text--", radio_status); } });
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton radioButton = (RadioButton) group.findViewById(checkedId); String text = radioButton.getText().toString(); updated_list.add(text); } });
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); } } });
public void setDiskStorageType(DiskStorageType diskStorageType) { allButton.setValue(diskStorageType == null); imagesButton.setValue(diskStorageType == DiskStorageType.IMAGE); lunsButton.setValue(diskStorageType == DiskStorageType.LUN); cinderButton.setValue(diskStorageType == DiskStorageType.CINDER); managedBlockButton.setValue(diskStorageType == DiskStorageType.MANAGED_BLOCK_STORAGE); }
private Widget getRadioGroupPanel() { allButton = new RadioButton(GROUP_NAME); allButton.setText(constants.allDisksLabel()); allButton.setActive(true); allButton.addClickHandler(event -> fireChangeHandlers(null)); imagesButton = new RadioButton(GROUP_NAME); imagesButton.setText(constants.imageDisksLabel()); imagesButton.addClickHandler(event -> fireChangeHandlers(DiskStorageType.IMAGE)); lunsButton = new RadioButton(GROUP_NAME); lunsButton.setText(constants.lunDisksLabel()); lunsButton.addClickHandler(event -> fireChangeHandlers(DiskStorageType.LUN)); cinderButton = new RadioButton(GROUP_NAME); cinderButton.setText(constants.cinderDisksLabel()); cinderButton.addClickHandler(event -> fireChangeHandlers(DiskStorageType.CINDER)); managedBlockButton = new RadioButton(GROUP_NAME); managedBlockButton.setText(constants.managedBlockDisksLabel()); managedBlockButton.addClickHandler(event -> fireChangeHandlers(DiskStorageType.MANAGED_BLOCK_STORAGE)); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.setDataToggle(Toggle.BUTTONS); buttonGroup.add(allButton); buttonGroup.add(imagesButton); buttonGroup.add(lunsButton); buttonGroup.add(cinderButton); buttonGroup.add(managedBlockButton); buttonGroup.addStyleName("disk-type-buttons-group"); //$NON-NLS-1$ return buttonGroup; }
private RadioButton createRadioButton(String title, boolean active, boolean enabled, ValueChangeHandler<Boolean> handler) { RadioButton button = new RadioButton(title); button.setHTML(title); button.setName(name); button.setEnabled(enabled); button.setActive(active); button.addValueChangeHandler(handler); return button; }
private Widget getRadioGroupPanel() { ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.setDataToggle(Toggle.BUTTONS); for (ViewFilter<K> item : items) { RadioButton radioButton = new RadioButton(GROUP_NAME); radioButton.setText(item.getText()); radioButton.addClickHandler(event -> fireChangeHandlers(item.getValue())); buttons.put(item.getValue(), radioButton); buttonGroup.add(radioButton); } setSelectedValue(items.get(0).getValue()); return buttonGroup; }
RadioButton r = (RadioButton) radioButton .getChildAt(idx); String selectedtext = r.getText().toString();
@Override public void addRendererItem(final String renderer) { final RadioButton rb = new RadioButton(renderer); rb.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { unselectCurrent(); presenter.onRendererSelected(); } }); radioButtonsPanel.add(rb); }
public void setSelectedValue(K value) { // Reset old selected radio K selected = getSelectedValue(); if (selected != null && buttons.get(selected) != null) { buttons.get(selected).setValue(false); buttons.get(selected).setActive(false); } // Initialize new selected radio if (value != null && buttons.get(value) != null) { buttons.get(value).setValue(true); buttons.get(value).setActive(true); } } }
/** * Creates a new radio button associated with a particular group, and * initialized with the given label (optionally treated as HTML). All radio * buttons associated with the same group name belong to a * mutually-exclusive set. * * Radio buttons are grouped by their name attribute, so changing their name * using the setName() method will also change their associated group. * * @param name * name the group with which to associate the radio button * @param label * this radio button's label * @param asHTML * <code>true</code> to treat the specified label as HTML */ public RadioButton(String name, String label, boolean asHTML) { this(name); if (asHTML) { setHTML(label); } else { setText(label); } }
/** * @see #RadioButtonToggle(String, SafeHtml) * * @param name * the group name with which to associate the radio button * @param label * this radio button's label * @param dir * the text's direction. Note that {@code DEFAULT} means * direction should be inherited from the widget's parent * element. */ public RadioButton(String name, String label, Direction dir) { this(name); setText(label, dir); }
/** * @see #RadioButtonToggle(String, SafeHtml) * * @param name * the group name with which to associate the radio button * @param label * this radio button's html label * @param directionEstimator * A DirectionEstimator object used for automatic direction * adjustment. For convenience, * {@link #DEFAULT_DIRECTION_ESTIMATOR} can be used. */ public RadioButton(String name, SafeHtml label, DirectionEstimator directionEstimator) { this(name); setDirectionEstimator(directionEstimator); setHTML(label.asString()); }