Java Code Examples for android.widget.RadioButton#isChecked()
The following examples show how to use
android.widget.RadioButton#isChecked() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignUp.java From Walk-In-Clinic-Android-App with MIT License | 6 votes |
@Override public void onClick(View v) { RadioButton rb1; RadioButton rb2; rb1 = findViewById(R.id.EmployeeRB); rb2 = findViewById(R.id.PatientRB); switch (v.getId()) { case R.id.createButton: if(validateForm()) { if (rb1.isChecked()) openEmployee(); else if (rb2.isChecked()) openPatient(); else { Toast.makeText(getApplicationContext(), "Please Choose a Role", Toast.LENGTH_LONG).show(); } } break; case R.id.backButton: openMain(); break; } }
Example 2
Source File: RadioGridGroup.java From MHViewer with Apache License 2.0 | 6 votes |
@Override public void addView(View child, int index, ViewGroup.LayoutParams params) { if (child instanceof RadioButton) { final RadioButton button = (RadioButton) child; if (button.isChecked()) { mProtectFromCheckedChange = true; if (mCheckedId != -1) { setCheckedStateForView(mCheckedId, false); } mProtectFromCheckedChange = false; setCheckedId(button.getId()); } } super.addView(child, index, params); }
Example 3
Source File: BindingAdapters.java From Flubber with Apache License 2.0 | 6 votes |
@BindingAdapter({"checked", "model"}) public static <T> void setChecked(RadioButton radioButton, final ObservableField<T> checked, final T model) { if (checked == null) { return; } radioButton.setOnCheckedChangeListener( (buttonView, isChecked) -> { if ((checked.get() == null || !checked.get().equals(model)) && isChecked) { checked.set(model); } }); final T checkedModel = checked.get(); final boolean shouldBeChecked = checkedModel != null && checkedModel.equals(model); if (shouldBeChecked != radioButton.isChecked()) { radioButton.setChecked(shouldBeChecked); } }
Example 4
Source File: MainActivity.java From SmallGdufe-Android with GNU General Public License v3.0 | 6 votes |
@OnClick({ R.id.rd_home, R.id.rd_features,R.id.rd_me }) public void onRadioButtonClicked(RadioButton radioButton) { boolean checked = radioButton.isChecked(); switch (radioButton.getId()) { case R.id.rd_home: if (checked) { fUtil.show(mFragments.get(0));break; } case R.id.rd_features: if (checked) { fUtil.show(mFragments.get(1));break; } case R.id.rd_social: if (checked) { fUtil.show(mFragments.get(2));break; } case R.id.rd_me: if (checked) { if(isAlpha){ fUtil.show(mFragments.get(3));break; }else{ fUtil.show(mFragments.get(2));break; } } } }
Example 5
Source File: SelectOneAutoAdvanceWidget.java From commcare-android with Apache License 2.0 | 6 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!buttonView.isPressed()) { return; } if (!isChecked) { // If it got unchecked, we don't care. return; } for (RadioButton button : this.buttons) { if (button.isChecked() && !(buttonView == button)) { button.setChecked(false); } } widgetEntryChanged(); listener.advance(); }
Example 6
Source File: Reminders.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private long getPeriod(RadioButton rbday, RadioButton rbhour, RadioButton rbweek) { long period; try { period = Integer.parseInt(reminderDaysEdt.getText().toString()); } catch (NumberFormatException e) { period = 1; // TODO avoid this happening from the UI try { reminderDaysEdt.setText("" + period); } catch (Exception ee) { // } } if (rbday.isChecked()) { period = period * Constants.DAY_IN_MS; } else if (rbhour.isChecked()) { period = period * Constants.HOUR_IN_MS; } else if (rbweek.isChecked()) { period = period * Constants.WEEK_IN_MS; } return period; }
Example 7
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
public void onClick(View view) { switch (view.getId()) { case R.id.button1: RadioButton celsiusButton = (RadioButton) findViewById(R.id.radio0); RadioButton fahrenheitButton = (RadioButton) findViewById(R.id.radio1); if (text.getText().length() == 0) { Toast.makeText(this, "Please enter a valid number", Toast.LENGTH_LONG).show(); return; } float inputValue = Float.parseFloat(text.getText().toString()); if (celsiusButton.isChecked()) { text.setText(String .valueOf(ConverterUtil.convertFahrenheitToCelsius(inputValue))); celsiusButton.setChecked(false); fahrenheitButton.setChecked(true); } else { text.setText(String .valueOf(ConverterUtil.convertCelsiusToFahrenheit(inputValue))); fahrenheitButton.setChecked(false); celsiusButton.setChecked(true); } break; } }
Example 8
Source File: SearchIssuesActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void browse(View view) { BrowseConfig config = new BrowseConfig(); config.typeFilter = "Public"; RadioButton radio = (RadioButton)findViewById(R.id.personalRadio); if (radio.isChecked()) { config.typeFilter = "Personal"; } Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin); config.sort = (String)sortSpin.getSelectedItem(); AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText); config.tag = tagText.getText().toString(); //AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText); //config.category = categoryText.getText().toString(); EditText filterEdit = (EditText)findViewById(R.id.filterText); config.filter = filterEdit.getText().toString(); //CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox); //MainActivity.showImages = checkbox.isChecked(); config.type = "Issue"; if (MainActivity.instance != null) { config.instance = MainActivity.instance.id; } HttpAction action = new HttpGetIssuesAction(this, config); action.execute(); }
Example 9
Source File: ListWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { // If it got unchecked, we don't care. return; } for (RadioButton button : this.buttons) { if (button.isChecked() && !(buttonView == button)) { button.setChecked(false); } } widgetEntryChanged(); }
Example 10
Source File: SearchPostsActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void browse(View view) { BrowseConfig config = new BrowseConfig(); config.typeFilter = "Public"; RadioButton radio = (RadioButton)findViewById(R.id.personalRadio); if (radio.isChecked()) { config.typeFilter = "Personal"; } Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin); config.sort = (String)sortSpin.getSelectedItem(); AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText); config.tag = (String)tagText.getText().toString(); AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText); config.category = (String)categoryText.getText().toString(); EditText filterEdit = (EditText)findViewById(R.id.filterText); config.filter = filterEdit.getText().toString(); CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox); MainActivity.showImages = checkbox.isChecked(); config.type = "Post"; if (MainActivity.instance != null) { config.instance = MainActivity.instance.id; } HttpAction action = new HttpGetPostsAction(this, config); action.execute(); }
Example 11
Source File: SearchIssuesActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void browse(View view) { BrowseConfig config = new BrowseConfig(); config.typeFilter = "Public"; RadioButton radio = (RadioButton)findViewById(R.id.personalRadio); if (radio.isChecked()) { config.typeFilter = "Personal"; } Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin); config.sort = (String)sortSpin.getSelectedItem(); AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText); config.tag = tagText.getText().toString(); //AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText); //config.category = categoryText.getText().toString(); EditText filterEdit = (EditText)findViewById(R.id.filterText); config.filter = filterEdit.getText().toString(); //CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox); //MainActivity.showImages = checkbox.isChecked(); config.type = "Issue"; if (MainActivity.instance != null) { config.instance = MainActivity.instance.id; } HttpAction action = new HttpGetIssuesAction(this, config); action.execute(); }
Example 12
Source File: SearchPostsActivity.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void browse(View view) { BrowseConfig config = new BrowseConfig(); config.typeFilter = "Public"; RadioButton radio = (RadioButton)findViewById(R.id.personalRadio); if (radio.isChecked()) { config.typeFilter = "Personal"; } Spinner sortSpin = (Spinner)findViewById(R.id.sortSpin); config.sort = (String)sortSpin.getSelectedItem(); AutoCompleteTextView tagText = (AutoCompleteTextView)findViewById(R.id.tagsText); config.tag = (String)tagText.getText().toString(); AutoCompleteTextView categoryText = (AutoCompleteTextView)findViewById(R.id.categoriesText); config.category = (String)categoryText.getText().toString(); EditText filterEdit = (EditText)findViewById(R.id.filterText); config.filter = filterEdit.getText().toString(); CheckBox checkbox = (CheckBox)findViewById(R.id.imagesCheckBox); MainActivity.showImages = checkbox.isChecked(); config.type = "Post"; if (MainActivity.instance != null) { config.instance = MainActivity.instance.id; } HttpAction action = new HttpGetPostsAction(this, config); action.execute(); }
Example 13
Source File: InflectionQuizActivity.java From aedict with GNU General Public License v3.0 | 5 votes |
private int getSelected() { for (final Map.Entry<Integer, Integer> e : OPTION_TO_ID.entrySet()) { final RadioButton btn = (RadioButton) findViewById(e.getValue()); if (btn.isChecked()) { return e.getKey(); } } throw new AssertionError(); }
Example 14
Source File: SelectOneWidget.java From commcare-android with Apache License 2.0 | 5 votes |
private int getCheckedId() { for (RadioButton button : this.buttons) { if (button.isChecked()) { return button.getId(); } } return -1; }
Example 15
Source File: RecordFBOActivity.java From pause-resume-video-recording with Apache License 2.0 | 5 votes |
/** * onClick handler for radio buttons. */ public void onRadioButtonClicked(View view) { RadioButton rb = (RadioButton) view; if (!rb.isChecked()) { Log.d(TAG, "Got click on non-checked radio button"); return; } switch (rb.getId()) { case R.id.recDrawTwice_radio: mSelectedRecordMethod = RECMETHOD_DRAW_TWICE; break; case R.id.recFbo_radio: mSelectedRecordMethod = RECMETHOD_FBO; break; case R.id.recFramebuffer_radio: mSelectedRecordMethod = RECMETHOD_BLIT_FRAMEBUFFER; break; default: throw new RuntimeException("Click from unknown id " + rb.getId()); } Log.d(TAG, "Selected rec mode " + mSelectedRecordMethod); RenderHandler rh = mRenderThread.getHandler(); if (rh != null) { rh.setRecordMethod(mSelectedRecordMethod); } }
Example 16
Source File: ListWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void clearAnswer() { for (RadioButton button : this.buttons) { if (button.isChecked()) { button.setChecked(false); return; } } }
Example 17
Source File: SelectOneAutoAdvanceWidget.java From commcare-android with Apache License 2.0 | 5 votes |
@Override public void clearAnswer() { for (RadioButton button : this.buttons) { if (button.isChecked()) { button.setChecked(false); return; } } }
Example 18
Source File: ListWidget.java From commcare-android with Apache License 2.0 | 5 votes |
private int getCheckedId() { for (RadioButton button : this.buttons) { if (button.isChecked()) { return button.getId(); } } return -1; }
Example 19
Source File: SelectOneAutoAdvanceWidget.java From commcare-android with Apache License 2.0 | 5 votes |
private int getCheckedId() { for (RadioButton button : this.buttons) { if (button.isChecked()) { return button.getId(); } } return -1; }
Example 20
Source File: TagEdit.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void updateTagInOSMElement() { // check boxes if (odkTag != null && checkBoxMode) { boolean editTextCheckBoxChecked = editTextCheckBox.isChecked(); if (odkTag.hasCheckedTagValues() || editTextCheckBoxChecked) { if (editTextCheckBoxChecked) { setTagVal(odkTag.getSemiColonDelimitedTagValues(checkBoxEditText.getText().toString())); } else { setTagVal(odkTag.getSemiColonDelimitedTagValues(null)); } addOrEditTag(tagKey, tagVal); } else { deleteTag(tagKey); } return; } // radio buttons if (radioGroup != null && odkTag != null) { View v = radioGroup.getChildAt(radioGroup.getChildCount() - 1); int checkedId = radioGroup.getCheckedRadioButtonId(); // has custom value input if (v instanceof LinearLayout) { LinearLayout customLL = (LinearLayout)v; RadioButton customRadio = (RadioButton)customLL.getChildAt(0); if (customRadio.isChecked()) { EditText et = (EditText)customLL.getChildAt(1); setTagVal(et.getText().toString()); addOrEditTag(tagKey, tagVal); } else if (checkedId != -1) { setTagVal(odkTag.getTagItemValueFromButtonId(checkedId)); addOrEditTag(tagKey, tagVal); } else { deleteTag(tagKey); } } // no custom value input else { if (checkedId != -1) { setTagVal(odkTag.getTagItemValueFromButtonId(checkedId)); addOrEditTag(tagKey, tagVal); } else { deleteTag(tagKey); } } } // edit text else if (editText != null) { setTagVal(editText.getText().toString()); addOrEditTag(tagKey, tagVal); } }