Java Code Examples for android.widget.RadioButton#getId()
The following examples show how to use
android.widget.RadioButton#getId() .
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: MultiLineRadioGroup.java From DoraemonKit with Apache License 2.0 | 6 votes |
/** * Checks the radio button with the specified id. * If the specified id is not found does nothing. * * @param id the radio button's id */ @Override public void check(int id) { if (id <= 0) return; for (RadioButton radioButton : mRadioButtons) { if (radioButton.getId() == id) { if (checkButton(radioButton)) { // True if the button wasn't already checked. if (mOnCheckedChangeListener != null) { mOnCheckedChangeListener.onCheckedChanged( MultiLineRadioGroup.this, radioButton); } } return; } } }
Example 2
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 3
Source File: AdvancedOptionsDialogFragment.java From reflow-animator with Apache License 2.0 | 6 votes |
@OnCheckedChanged({ R.id.source_align_start, R.id.source_align_center, R.id.source_align_end }) void onSourceAlignmentChanged(RadioButton button, boolean isChecked) { if (isChecked) { int alignment = Gravity.NO_GRAVITY; switch (button.getId()) { case R.id.source_align_start: alignment = Gravity.START; break; case R.id.source_align_center: alignment = Gravity.CENTER_HORIZONTAL; break; case R.id.source_align_end: alignment = Gravity.END; break; } onUpdateListener.updateSourceTextAlignment(alignment); } }
Example 4
Source File: AdvancedOptionsDialogFragment.java From reflow-animator with Apache License 2.0 | 6 votes |
@OnCheckedChanged({ R.id.target_align_start, R.id.target_align_center, R.id.target_align_end }) void onTargetAlignmentChanged(RadioButton button, boolean isChecked) { if (isChecked) { int alignment = Gravity.NO_GRAVITY; switch (button.getId()) { case R.id.target_align_start: alignment = Gravity.START; break; case R.id.target_align_center: alignment = Gravity.CENTER_HORIZONTAL; break; case R.id.target_align_end: alignment = Gravity.END; break; } onUpdateListener.updateTargetTextAlignment(alignment); } }
Example 5
Source File: MultiLineRadioGroup.java From MultiLineRadioGroup with MIT License | 6 votes |
/** * Checks the radio button with the specified id. * If the specified id is not found does nothing. * * @param id the radio button's id */ @Override public void check(int id) { if (id <= 0) return; for (RadioButton radioButton : mRadioButtons) { if (radioButton.getId() == id) { if (checkButton(radioButton)) { // True if the button wasn't already checked. if (mOnCheckedChangeListener != null) { mOnCheckedChangeListener.onCheckedChanged( MultiLineRadioGroup.this, radioButton); } } return; } } }
Example 6
Source File: KeyEventProfileActivity.java From DeviceConnect-Android with MIT License | 6 votes |
@Override public void onCheckedChanged(final RadioGroup group, final int checkedId) { RadioButton radioButton = findViewById(checkedId); // Change key mode. int i = radioButton.getId(); if (i == R.id.radioButton1) { mKeyMode = KeyMode.STD_KEY; } else if (i == R.id.radioButton2) { mKeyMode = KeyMode.MEDIA_CTRL; } else if (i == R.id.radioButton3) { mKeyMode = KeyMode.DPAD_BUTTON; } else if (i == R.id.radioButton4) { mKeyMode = KeyMode.USER; } }
Example 7
Source File: ComprehensionTemplate.java From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> options, int id, Context context) { for (RadioButton button : buttons) { if (button.getId() == id) { int index = buttons.indexOf(button); if ("".equals(options.get(index).getText().toString().trim())) { options.get(index).setError(context.getString(R.string.valid_before_setting_answer)); button.setChecked(false); return; } else { button.setChecked(true); } } else { button.setChecked(false); } } }
Example 8
Source File: QuizAdapter.java From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> options, int id, Context context) { for (RadioButton button : buttons) { if (button.getId() == id) { int index = buttons.indexOf(button); if (options.get(index).getText().toString().equals("")) { Toast.makeText(context, "Enter a valid option before marking it as answer", Toast.LENGTH_LONG).show(); button.setChecked(false); return; } else { button.setChecked(true); } } else { button.setChecked(false); } } }
Example 9
Source File: QuizTemplate.java From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> options, int id, Context context) { for (RadioButton button : buttons) { if (button.getId() == id) { int index = buttons.indexOf(button); if ("".equals(options.get(index).getText().toString().trim())) { options.get(index).setError(context.getString(R.string.valid_before_answer)); options.get(index).setText(null); button.setChecked(false); return; } else { button.setChecked(true); } } else { button.setChecked(false); } } }
Example 10
Source File: ComprehensionAdapter.java From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkButton(ArrayList<RadioButton> buttons, ArrayList<EditText> options, int id, Context context) { for (RadioButton button : buttons) { if (button.getId() == id) { int index = buttons.indexOf(button); if (options.get(index).getText().toString().equals("")) { Toast.makeText(context, "Enter a valid option before marking it as answer", Toast.LENGTH_LONG).show(); button.setChecked(false); return; } else { button.setChecked(true); } } else { button.setChecked(false); } } }
Example 11
Source File: RecordFBOActivity.java From grafika 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 12
Source File: HardwareScalerActivity.java From grafika with Apache License 2.0 | 5 votes |
/** * onClick handler for radio buttons. */ public void onRadioButtonClicked(View view) { int newSize; RadioButton rb = (RadioButton) view; if (!rb.isChecked()) { Log.d(TAG, "Got click on non-checked radio button"); return; } switch (rb.getId()) { case R.id.surfaceSizeTiny_radio: newSize = SURFACE_SIZE_TINY; break; case R.id.surfaceSizeSmall_radio: newSize = SURFACE_SIZE_SMALL; break; case R.id.surfaceSizeMedium_radio: newSize = SURFACE_SIZE_MEDIUM; break; case R.id.surfaceSizeFull_radio: newSize = SURFACE_SIZE_FULL; break; default: throw new RuntimeException("Click from unknown id " + rb.getId()); } mSelectedSize = newSize; int[] wh = mWindowWidthHeight[newSize]; // Update the Surface size. This causes a "surface changed" event, but does not // destroy and re-create the Surface. SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView); SurfaceHolder sh = sv.getHolder(); Log.d(TAG, "setting size to " + wh[0] + "x" + wh[1]); sh.setFixedSize(wh[0], wh[1]); }
Example 13
Source File: RadioButtonViewSample.java From pixate-freestyle-android with Apache License 2.0 | 5 votes |
@Override public void createViews(Context context, ViewGroup layout) { RadioGroup group = new RadioGroup(context); TextView tv = new TextView(context); PixateFreestyle.setStyleId(tv, "rgTitle"); tv.setText("Will you be attending?"); tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); group.addView(tv); String[] titles = new String[] { "Yes", "No", "Maybe" }; Integer id = null; for (String title : titles) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); RadioButton rb = new RadioButton(context); PixateFreestyle.setStyleClass(rb, "myRadioButton"); PixateFreestyle.setStyleId(rb, "myRadioButton" + title); rb.setText(title); group.addView(rb, params); if (id == null) { id = rb.getId(); } } layout.addView(group, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); group.check(id); addView(group); }
Example 14
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 15
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 16
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 17
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 18
Source File: RadioButtonGroupHelper.java From AndroidProject with Apache License 2.0 | 5 votes |
public RadioButtonGroupHelper(RadioButton... groups) { mViewSet = new ArrayList<>(groups.length - 1); for (RadioButton view : groups) { // 如果这个RadioButton没有设置id的话 if (view.getId() == View.NO_ID) { throw new IllegalArgumentException("are you ok?"); } view.setOnCheckedChangeListener(this); mViewSet.add(view); } }