@Override public void onCheckedChanged(RadioGroup group, int checkedId) { PreferenceManager.getDefaultSharedPreferences(getActivity()) .edit().putInt(getArguments().getString(ARG_TITLE), group .indexOfChild(group.findViewById(group .getCheckedRadioButtonId()))).commit(); } });
final int indexOfChild = radioGroup.indexOfChild( radioGroup.findViewById(radioGroup.getCheckedRadioButtonId())); final AdapterChoiceItem choice = choices.get(indexOfChild); final int indexOfChild = radioGroup.indexOfChild(v); if (indexOfChild == -1) return;
@Override public void onCheckedChanged(RadioGroup radioGroup, int i) { View radioButton = radioGroup.findViewById(i); int index = radioGroup.indexOfChild(radioButton); String host = address[index]; SharedPreferences.Editor edit = mPrefs.edit(); edit.putString(Config.SP_SERVER_HOST, host); edit.apply(); } });
RadioGroup group= (RadioGroup) getView().findViewById(R.id.radioGroup); group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { View radioButton = radioGroup.findViewById(i); int index = radioGroup.indexOfChild(radioButton); } });
@Override public void finish() { if (mIsCancelled) { setResult(RESULT_CANCELED); } else { RadioGroup group = (RadioGroup) findViewById(R.id.radioProfiles); int selectedId = group.getCheckedRadioButtonId(); RadioButton radioButton = (RadioButton) findViewById(selectedId); String action = radioButton.getText().toString(); final Intent resultIntent = new Intent(); if (!G.isProfileMigrated()) { int idx = group.indexOfChild(radioButton); resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, PluginBundleManager.generateBundle(getApplicationContext(), idx + "::" + action)); } else { resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, PluginBundleManager.generateBundle(getApplicationContext(), selectedId + "::" + action)); } resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, action); setResult(RESULT_OK, resultIntent); } super.finish(); } }
@Override public void onCheckedChanged(RadioGroup radioGroup, int i) { vp.setCurrentItem(radioGroup.indexOfChild(radioGroup.findViewById(i))); } });
private void saveRadioChoice(){ SharedPreferences mSharedPref = getSharedPreferences(MY_PREF_KEY,MODE_PRIVATE); SharedPreferences.Editor editor = mSharedPref.edit(); // Initialize Radiogroup while saving choices RadioGroup localRadioGroup = (RadioGroup) findViewById(R.id.choices); editor.putInt(my_choice_key, localRadioGroup.indexOfChild(findViewById(localRadioGroup.getCheckedRadioButtonId()))); editor.apply(); }
RadioGroup group= (RadioGroup) getView().findViewById(R.id.radioGroup); group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { View radioButton = radioGroup.findViewById(i); int index = radioGroup.indexOfChild(radioButton); } });
final RadioGroup radio = (RadioGroup) dialog.findViewById(R.id.radioGroup1); radio.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { View radioButton = radio.findViewById(checkedId); int index = radio.indexOfChild(radioButton); // Add logic here switch (index) { case 0: // first button Toast.makeText(getApplicationContext(), "Selected button number " + index, 500).show(); break; case 1: // secondbutton Toast.makeText(getApplicationContext(), "Selected button number " + index, 500).show(); break; } } });
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { View radioButton = radioGroup.findViewById(checkedId); int index = radioGroup.indexOfChild(radioButton); TextView textView = rootView.findViewById(R.id.fragment_header); switch (index) { case YES: // User chose "Yes". textView.setText(R.string.yes_message); break; case NO: // User chose "No". textView.setText(R.string.no_message); break; default: // No choice made. // Do nothing. break; } } });
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { View radioButton = radioGroup.findViewById(checkedId); int index = radioGroup.indexOfChild(radioButton); TextView textView = rootView.findViewById(R.id.fragment_header); switch (index) { case YES: // User chose "Yes". textView.setText(R.string.yes_message); break; case NO: // User chose "No". textView.setText(R.string.no_message); break; default: // No choice made. // Do nothing. break; } } });
RadioGroup rbGroup = (RadioGroup)findViewById(R.id.radiogroup); int RadioButtonId=rbGroup.getCheckedRadioButtonId(); View radioButton = rbGroup.findViewById(RadioButtonId); String = Integer.toString(rbGroup.indexOfChild(radioButton)+1);
//complete code.. //rgp is your radio group rgp.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int radioButtonID = group.getCheckedRadioButtonId(); View radioButton = group.findViewById(radioButtonID); int position = group.indexOfChild(radioButton); } });
@Override public void onCheckedChanged(RadioGroup radioGroup, int i) { View radioButton = radioGroup.findViewById(i); int idx = radioGroup.indexOfChild(radioButton); radioGroupField.setAnswer(idx); } });
for(RadioGroup radioButtonGroup:RadioGroupList){ int radioButtonID = radioButtonGroup.getCheckedRadioButtonId(); View radioButton = radioButtonGroup.findViewById(radioButtonID); int idx = radioButtonGroup.indexOfChild(radioButton); }
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { int index = mRadioGroup.indexOfChild(group.findViewById(checkedId)); ODataRow row = items.get(index); setValue(row.getInt(OColumn.ROW_ID)); }
private void sendEditIdea() { String new_text = mIdeaField.getText().toString(); if (!new_text.equals("")) { if (mRadioGroup.getCheckedRadioButtonId() != -1) { View radioButton = mRadioGroup.findViewById(mRadioGroup.getCheckedRadioButtonId()); RadioButton btn = (RadioButton) mRadioGroup.getChildAt(mRadioGroup.indexOfChild(radioButton)); String selection = (String) btn.getText(); String new_note = mNoteField.getText().toString(); boolean new_later = mDoLater.isChecked(); int new_priority = Integer.parseInt(selection); mDbHelper.editEntry(mIdRecycler, new_text, new_note, new_priority, new_later); } mEditIdeaDialog.dismiss(); } else { mError.setVisibility(View.VISIBLE); } }
@Override public boolean onMenuItemClick(MenuItem item) { int radioButtonID = rg.getCheckedRadioButtonId(); View radioButton = rg.findViewById(radioButtonID); int idx = rg.indexOfChild(radioButton); if (idx == -1) { db.markUnAnswered(Integer.parseInt(finalQuestionId)); } else { db.markAnswered(Integer.parseInt(finalQuestionId), idx); } Bundle arguments = new Bundle(); arguments.putString(Intent.EXTRA_TEXT, String.valueOf(finalI)); Fragment frag = QuestionFragment.newInstance(); frag.setArguments(arguments); getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit(); return false; } });
@Override public boolean onMenuItemClick(MenuItem item) { int radioButtonID = rg.getCheckedRadioButtonId(); View radioButton = rg.findViewById(radioButtonID); int idx = rg.indexOfChild(radioButton); if (idx == -1) { db.markUnAnswered(Integer.parseInt(finalQuestionId)); } else { db.markAnswered(Integer.parseInt(finalQuestionId), idx); } Bundle arguments = new Bundle(); arguments.putString(Intent.EXTRA_TEXT, String.valueOf(finalI)); Fragment frag = QuestionFragment.newInstance(); frag.setArguments(arguments); getActivity().getSupportFragmentManager().beginTransaction().replace(((ViewGroup) getView().getParent()).getId(), frag).addToBackStack(null).commit(); return false; } });
@Override String getResult() { int radioIndex = radioGroup.indexOfChild(widgetView.findViewById(radioGroup.getCheckedRadioButtonId())); RadioButton radioButton = (RadioButton) radioGroup.getChildAt(radioIndex); InputResult.index = radioIndex; return (radioButton != null) ? radioButton.getText().toString() : ""; } }