List of usage examples for android.widget RadioGroup getCheckedRadioButtonId
@IdRes public int getCheckedRadioButtonId()
Returns the identifier of the selected radio button in this group.
From source file:com.tbay.android.FrequentSMS.MainActivity.java
/** * SMSSelected change the text in the editable field according to the user * selection in the radio buttons./*w ww. j a va 2s . c om*/ */ public void SMSSelected(View view) { RadioGroup rg = (RadioGroup) findViewById(R.id.whichSMS); int rbid = rg.getCheckedRadioButtonId(); EditText Txt = (EditText) findViewById(R.id.SMSText); EditText et = (EditText) findViewById(R.id.LogTexts); switch (rbid) { case R.id.Wifi: mAppPrefs.SelectionId = 0; Txt.setText(AppPreferences.Key1_Msg); et.append(AppPreferences.Key1_Msg + "\n"); break; case R.id.Aftensmad: mAppPrefs.SelectionId = 1; Txt.setText(AppPreferences.Key2_Msg); et.append(AppPreferences.Key2_Msg + "\n"); break; case R.id.Snart_hjemme: mAppPrefs.SelectionId = 2; Txt.setText(AppPreferences.Key3_Msg); et.append(AppPreferences.Key3_Msg + "\n"); break; case R.id.TestSMS: mAppPrefs.SelectionId = 3; Txt.setText(AppPreferences.Key4_Msg); et.append(AppPreferences.Key4_Msg + "\n"); break; } // Save time for SMS transmission in preferences mAppPrefs.savePreferences(getApplicationContext()); }
From source file:com.mycodehurts.rapidmath.app.HomeActivity.java
public void onBtnClicked(View v) { if (v.getId() == R.id.btnGetMeStarted) { //handle the click here EditText txtProfileName = (EditText) findViewById(R.id.txtProfileName); RadioGroup chkSex = (RadioGroup) findViewById(R.id.sexGroup); Spinner spnrAge = (Spinner) findViewById(R.id.spinnerAge); if (txtProfileName.getText().toString().length() == 0) { Toast.makeText(this.getApplicationContext(), "Missing Profile Name", 3).show(); txtProfileName.requestFocus(); return; }//from w w w . j a v a 2 s. c o m if (chkSex.getCheckedRadioButtonId() == -1) { Toast.makeText(this.getApplicationContext(), "Male / Female - Choose one!", 3).show(); return; } SharedPreferences store = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = store.edit(); editor.putString("strProfileName", txtProfileName.getText().toString()); if (chkSex.getCheckedRadioButtonId() == R.id.sexMale) editor.putString("strSex", "Male"); else editor.putString("strSex", "Female"); editor.putInt("iAgeGroup", spnrAge.getSelectedItemPosition()); editor.commit(); ((RMApplication) getApplication()).getTracker(RMApplication.TrackerName.APP_TRACKER) .send(new HitBuilders.EventBuilder().setCategory("Registration") .setAction(chkSex.getCheckedRadioButtonId() == R.id.sexMale ? "Male" : "Female") .setValue(spnrAge.getSelectedItemPosition()).build()); //Load next activity. Intent intent = new Intent(this, ProfilePage.class); startActivity(intent); } }
From source file:conversandroid.RichASR.java
/** * Reads the values for the language model and the maximum number of recognition results * from the GUI//from www . j av a2s.co m */ private void setRecognitionParams() { String numResults = ((EditText) findViewById(R.id.numResults_editText)).getText().toString(); //Converts String into int, if it is not possible, it uses the default value try { numberRecoResults = Integer.parseInt(numResults); } catch (Exception e) { numberRecoResults = DEFAULT_NUMBER_RESULTS; } //If the number is <= 0, it uses the default value if (numberRecoResults <= 0) numberRecoResults = DEFAULT_NUMBER_RESULTS; RadioGroup radioG = (RadioGroup) findViewById(R.id.langModel_radioGroup); switch (radioG.getCheckedRadioButtonId()) { case R.id.langModelFree_radio: languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM; break; case R.id.langModelWeb_radio: languageModel = RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH; break; default: languageModel = DEFAULT_LANG_MODEL; break; } }
From source file:org.egov.android.view.activity.EditProfileActivity.java
/** * Function called when click on edit profile. Check the empty fields validation and call edit * profile api./*ww w .j a v a 2 s .co m*/ */ @SuppressLint("DefaultLocale") private void _editProfile() { String name = ((EditText) findViewById(R.id.edit_profile_name)).getText().toString().trim(); String alt_conatct_no = ((EditText) findViewById(R.id.edit_profile_alt_contact)).getText().toString() .trim(); String date_of_birth = ((TextView) findViewById(R.id.edit_profile_dob)).getText().toString(); String panNo = ((EditText) findViewById(R.id.edit_profile_pan)).getText().toString().trim(); String aadhaarNo = ((EditText) findViewById(R.id.edit_profile_aadhaar)).getText().toString().trim(); RadioGroup gender = (RadioGroup) findViewById(R.id.gender); int genderSelected = gender.getCheckedRadioButtonId(); RadioButton genderButton = (RadioButton) findViewById(genderSelected); if (isEmpty(name)) { showMessage(getMessage(R.string.name_empty)); return; } else if (name.length() < 3) { showMessage(getMessage(R.string.name_length)); return; } else if (!isEmpty(alt_conatct_no) && alt_conatct_no.length() != 10) { showMessage(getMessage(R.string.phone_number_length)); return; } else if (isEmpty(date_of_birth)) { showMessage(getMessage(R.string.birth_empty)); return; } else if (!isEmpty(panNo) && panNo.length() != 10) { showMessage(getMessage(R.string.pan_card_length)); return; } else if (!isEmpty(aadhaarNo) && aadhaarNo.length() != 12) { showMessage(getMessage(R.string.aadhaar_length)); return; } String[] parts = date_of_birth.split("-"); User user = new User(); user.setName(name); user.setGender(genderButton.getText().toString().toUpperCase()); user.setAltContactNumber(alt_conatct_no); user.setDateOfBirth(parts[2] + "-" + parts[1] + "-" + parts[0]); user.setPanCardNumber(panNo); user.setAadhaarCardNumber(aadhaarNo); user.setEmail(mailId); user.setMobileNo(mobileNo); ApiController.getInstance().updateProfile(this, user); }
From source file:com.hp.mss.printsdksample.fragment.TabFragmentPrintLayout.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflatedView = inflater.inflate(R.layout.tab_fragment_print_layout, container, false); filePickerLayout = (RelativeLayout) inflatedView.findViewById(R.id.filePickerLayout); RadioGroup layoutRadioGroup = (RadioGroup) inflatedView.findViewById(R.id.layoutRadioGroup); layoutRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(layoutRadioGroup, layoutRadioGroup.getCheckedRadioButtonId()); RadioGroup layoutMarginRadioGroup = (RadioGroup) inflatedView.findViewById(R.id.layoutMarginRadioGroup); layoutMarginRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(layoutMarginRadioGroup, layoutMarginRadioGroup.getCheckedRadioButtonId()); SwitchCompat metricsSwitch = (SwitchCompat) inflatedView.findViewById(R.id.metricsRadioGroup); metricsSwitch.setOnCheckedChangeListener(this); onCheckedChanged(metricsSwitch, metricsSwitch.isChecked()); RadioGroup contentRadioGroup = (RadioGroup) inflatedView.findViewById(R.id.contentRadioGroup); contentRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(contentRadioGroup, contentRadioGroup.getCheckedRadioButtonId()); RadioGroup deviceIdRadioGroup = (RadioGroup) inflatedView.findViewById(R.id.deviceIdRadioGroup); deviceIdRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(deviceIdRadioGroup, deviceIdRadioGroup.getCheckedRadioButtonId()); tagText = (EditText) inflatedView.findViewById(R.id.tagEditText); valueText = (EditText) inflatedView.findViewById(R.id.valueEditText); LinearLayout customData = (LinearLayout) inflatedView.findViewById(R.id.customData); showCustomData = customData.getVisibility() == View.VISIBLE; FloatingActionButton printButton = (FloatingActionButton) inflatedView.findViewById(R.id.printBtn); printButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { continueButtonClicked(v);/*ww w.ja va2 s . co m*/ } }); Button buttonPick = (Button) inflatedView.findViewById(R.id.buttonPick); buttonPick.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(getContentMimeType()); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICKFILE_RESULT_CODE); } }); mediaSize5x7 = new PrintAttributes.MediaSize("na_5x7_5x7in", "5 x 7", 5000, 7000); return inflatedView; }
From source file:org.github.allancth.fcm.android.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final EditText nameEditText = (EditText) findViewById(R.id.name); final EditText messageEditText = (EditText) findViewById(R.id.message); final RadioGroup optionsRadioGroup = (RadioGroup) findViewById(R.id.options); final String senderId = getString(R.string.sender_id); Button send = (Button) findViewById(R.id.send); send.setOnClickListener(new View.OnClickListener() { @Override//from w ww .j a va2s . c o m public void onClick(View view) { String name = nameEditText.getText().toString(); String message = messageEditText.getText().toString(); Option option = null; switch (optionsRadioGroup.getCheckedRadioButtonId()) { case R.id.receive_message: { option = Option.MESSAGE; break; } case R.id.receive_notification: { option = Option.NOTIFICATION; break; } } if (name.isEmpty()) { Toast.makeText(MainActivity.this, R.string.name_is_empty, Toast.LENGTH_SHORT).show(); return; } else if (message.isEmpty()) { Toast.makeText(MainActivity.this, R.string.message_is_empty, Toast.LENGTH_SHORT).show(); return; } else if (option == null) { Toast.makeText(MainActivity.this, R.string.option_is_empty, Toast.LENGTH_SHORT).show(); return; } else if (senderId.isEmpty()) { Toast.makeText(MainActivity.this, R.string.sender_id_is_empty, Toast.LENGTH_SHORT).show(); return; } RemoteMessage.Builder builder = new RemoteMessage.Builder(senderId) .setMessageId(UUID.randomUUID().toString()); builder.addData("name", name); builder.addData("message", message); builder.addData("type", option.name()); FirebaseMessaging.getInstance().send(builder.build()); } }); }
From source file:sandra.examples.oneshot.voicelaunch.VoiceLaunch.java
/** * Reads the values for the similarity threshold and algorithm from the GUI *//*from w ww . j a v a 2 s . co m*/ private void readGUIParameters() { //String selectedThreshold = ((EditText) findViewById(R.id.threshold_editText)).getText().toString(); try { similarityThreshold = seekBarValueToFloat( ((SeekBar) findViewById(R.id.threshold_seekBar)).getProgress()); } catch (Exception e) { similarityThreshold = DEFAULT_THRESHOLD; Log.e(LOGTAG, "The similarity threshold selected could not be used, using the default value instead"); } RadioGroup radioG = (RadioGroup) findViewById(R.id.measure_radioGroup); switch (radioG.getCheckedRadioButtonId()) { case R.id.orthographic_radio: similarityCalculation = SimilarityAlgorithm.ORTHOGRAPHIC; break; case R.id.phonetic_radio: similarityCalculation = SimilarityAlgorithm.PHONETIC; break; default: similarityCalculation = DEFAULT_ALGORITHM; Log.e(LOGTAG, "The similarity algorithm selected could not be used, using the default algorithm instead"); break; } }
From source file:com.smc.jobs4smcyouth.Fragments.Print.PrintLayoutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflatedView = inflater.inflate(com.smc.jobs4smcyouth.R.layout.fragment_print_layout, container, false);/*from w ww .j av a 2 s.com*/ filePickerLayout = (RelativeLayout) inflatedView.findViewById(com.smc.jobs4smcyouth.R.id.filePickerLayout); RadioGroup layoutRadioGroup = (RadioGroup) inflatedView .findViewById(com.smc.jobs4smcyouth.R.id.layoutRadioGroup); layoutRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(layoutRadioGroup, layoutRadioGroup.getCheckedRadioButtonId()); RadioGroup layoutMarginRadioGroup = (RadioGroup) inflatedView .findViewById(com.smc.jobs4smcyouth.R.id.layoutMarginRadioGroup); layoutMarginRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(layoutMarginRadioGroup, layoutMarginRadioGroup.getCheckedRadioButtonId()); SwitchCompat metricsSwitch = (SwitchCompat) inflatedView .findViewById(com.smc.jobs4smcyouth.R.id.metricsRadioGroup); metricsSwitch.setOnCheckedChangeListener(this); onCheckedChanged(metricsSwitch, metricsSwitch.isChecked()); RadioGroup contentRadioGroup = (RadioGroup) inflatedView .findViewById(com.smc.jobs4smcyouth.R.id.contentRadioGroup); contentRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(contentRadioGroup, contentRadioGroup.getCheckedRadioButtonId()); RadioGroup deviceIdRadioGroup = (RadioGroup) inflatedView .findViewById(com.smc.jobs4smcyouth.R.id.deviceIdRadioGroup); deviceIdRadioGroup.setOnCheckedChangeListener(this); onCheckedChanged(deviceIdRadioGroup, deviceIdRadioGroup.getCheckedRadioButtonId()); tagText = (EditText) inflatedView.findViewById(com.smc.jobs4smcyouth.R.id.tagEditText); valueText = (EditText) inflatedView.findViewById(com.smc.jobs4smcyouth.R.id.valueEditText); LinearLayout customData = (LinearLayout) inflatedView.findViewById(com.smc.jobs4smcyouth.R.id.customData); showCustomData = customData.getVisibility() == View.VISIBLE; FloatingActionButton printButton = (FloatingActionButton) inflatedView .findViewById(com.smc.jobs4smcyouth.R.id.printBtn); printButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { continueButtonClicked(v); } }); Button buttonPick = (Button) inflatedView.findViewById(com.smc.jobs4smcyouth.R.id.buttonPick); buttonPick.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(getContentMimeType()); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICKFILE_RESULT_CODE); } }); mediaSize5x7 = new PrintAttributes.MediaSize("na_5x7_5x7in", "5 x 7", 5000, 7000); return inflatedView; }
From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFilesFragment.java
@Override public void onPositiveClicked(@Nullable View v) { if (v != null) { if (curDir != null && getFragmentManager().findFragmentByTag(TAG_PRIORITY_DIALOG) != null) { RadioGroup group = (RadioGroup) v.findViewById(R.id.dialog_priorities_group); int radioButtonId = group.getCheckedRadioButtonId(); List<TorrentContentFileTree> files = new ArrayList<>(); for (String name : selectedFiles) { files.add(curDir.getChild(name)); }/*from w w w . ja v a2 s.c o m*/ switch (radioButtonId) { case R.id.dialog_priority_low: setPriority(files, Priority.IGNORE); break; case R.id.dialog_priority_normal: setPriority(files, Priority.NORMAL); break; case R.id.dialog_priority_high: setPriority(files, Priority.SEVEN); break; default: /* No selected */ selectedFiles.clear(); return; } selectedFiles.clear(); } } }
From source file:com.gmail.srivi.sundaram.locgenie.MainActivity.java
public void getSuggestion(View v) { if (servicesConnected()) { Log.d(" ", "In getSuggestions_new"); EditText radius = (EditText) findViewById(R.id.editText1); String radiusCheck = radius.getText().toString(); // Getting the Selected Activity RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1); RadioButton selected = (RadioButton) findViewById(rg.getCheckedRadioButtonId()); String activity = (String) selected.getText(); if (radiusCheck.isEmpty()) { Toast.makeText(this, "Please Enter Radius", Toast.LENGTH_SHORT).show(); } else {/*from w w w . jav a 2 s. c o m*/ float miles = Float.valueOf(radius.getText().toString()); float meters = (float) (miles * 1609.344); String radiusInMeters = Float.toString(meters); Location currentLocation = mLocationClient.getLastLocation(); Intent intent = new Intent(getBaseContext(), DisplayPlacesActivity.class); intent.putExtra(EXTRA_MESSAGE, currentLocation); intent.putExtra(RADIUS, radiusInMeters); intent.putExtra(ACTIVITY, activity); startActivity(intent); } } }