List of usage examples for android.widget RadioGroup clearCheck
public void clearCheck()
Clears the selection.
From source file:jmri.enginedriver.intro_buttons.java
@SuppressWarnings("ConstantConditions") @Override//from ww w . j a va 2 s . co m public void onActivityCreated(@Nullable Bundle savedInstanceState) { Log.d("Engine_Driver", "intro_buttons"); super.onActivityCreated(savedInstanceState); prefs = this.getActivity().getSharedPreferences("jmri.enginedriver_preferences", 0); prefDisplaySpeedButtons = prefs.getBoolean("display_speed_arrows_buttons", false); prefHideSlider = prefs.getBoolean("hide_slider_preference", false); v = (RadioButton) getView().findViewById(R.id.intro_buttons_slider_name); v.setText(this.getActivity().getApplicationContext().getResources().getString(R.string.introButtonsSlider)); v = (RadioButton) getView().findViewById(R.id.intro_buttons_slider_and_buttons_name); v.setText(this.getActivity().getApplicationContext().getResources() .getString(R.string.introButtonsSliderAndButtons)); v = (RadioButton) getView().findViewById(R.id.intro_buttons_no_slider_name); v.setText( this.getActivity().getApplicationContext().getResources().getString(R.string.introButtonsNoSlider)); RadioGroup radioGroup = getView().findViewById(R.id.intro_buttons_radio_group); radioGroup.clearCheck(); if (!prefDisplaySpeedButtons && !prefHideSlider) { radioGroup.check(R.id.intro_buttons_slider_name); } else if (prefDisplaySpeedButtons && !prefHideSlider) { radioGroup.check(R.id.intro_buttons_slider_and_buttons_name); } else { radioGroup.check(R.id.intro_buttons_no_slider_name); } radioGroup.jumpDrawablesToCurrentState(); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @SuppressLint("ApplySharedPref") @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id.intro_buttons_slider_name) { displaySpeedButtons = false; hideSlider = false; } else if (checkedId == R.id.intro_buttons_slider_and_buttons_name) { displaySpeedButtons = true; hideSlider = false; } else if (checkedId == R.id.intro_buttons_no_slider_name) { displaySpeedButtons = true; hideSlider = true; } prefs.edit().putBoolean("display_speed_arrows_buttons", displaySpeedButtons).commit(); prefs.edit().putBoolean("hide_slider_preference", hideSlider).commit(); } }); }
From source file:jmri.enginedriver.intro_theme.java
@SuppressWarnings("ConstantConditions") @Override/* w ww .ja va 2 s. c om*/ public void onActivityCreated(@Nullable Bundle savedInstanceState) { Log.d("Engine_Driver", "intro_theme"); super.onActivityCreated(savedInstanceState); prefs = this.getActivity().getSharedPreferences("jmri.enginedriver_preferences", 0); currentValue = prefs.getString("prefTheme", this.getActivity().getApplicationContext().getResources() .getString(R.string.prefThemeDefaultValue)); nameEntries = this.getActivity().getApplicationContext().getResources() .getStringArray(R.array.prefThemeEntries); nameEntryValues = this.getActivity().getApplicationContext().getResources() .getStringArray(R.array.prefThemeEntryValues); v = (RadioButton) getView().findViewById(R.id.intro_theme_default_name); v.setText(nameEntries[0]); v = (RadioButton) getView().findViewById(R.id.intro_theme_black_name); v.setText(nameEntries[1]); v = (RadioButton) getView().findViewById(R.id.intro_theme_outline_name); v.setText(nameEntries[2]); v = (RadioButton) getView().findViewById(R.id.intro_theme_ultra_name); v.setText(nameEntries[3]); v = (RadioButton) getView().findViewById(R.id.intro_theme_colorful_name); v.setText(nameEntries[4]); RadioGroup radioGroup = getView().findViewById(R.id.intro_throttle_type_radio_group); radioGroup.clearCheck(); if (nameEntryValues[0].equals(currentValue)) { radioGroup.check(R.id.intro_theme_default_name); } else if (nameEntryValues[1].equals(currentValue)) { radioGroup.check(R.id.intro_theme_black_name); } else if (nameEntryValues[2].equals(currentValue)) { radioGroup.check(R.id.intro_theme_outline_name); } else if (nameEntryValues[3].equals(currentValue)) { radioGroup.check(R.id.intro_theme_ultra_name); } else if (nameEntryValues[4].equals(currentValue)) { radioGroup.check(R.id.intro_theme_colorful_name); } radioGroup.jumpDrawablesToCurrentState(); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @SuppressLint("ApplySharedPref") @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int Choice = 0; if (checkedId == R.id.intro_theme_default_name) { Choice = 0; } else if (checkedId == R.id.intro_theme_black_name) { Choice = 1; } else if (checkedId == R.id.intro_theme_outline_name) { Choice = 2; } else if (checkedId == R.id.intro_theme_ultra_name) { Choice = 3; } else if (checkedId == R.id.intro_theme_colorful_name) { Choice = 4; } prefs.edit().putString("prefTheme", nameEntryValues[Choice]).commit(); } }); }
From source file:jmri.enginedriver.intro_throttle_type.java
@SuppressWarnings("ConstantConditions") @Override/* www .j a va 2s. co m*/ public void onActivityCreated(@Nullable Bundle savedInstanceState) { Log.d("Engine_Driver", "intro_throttle_type"); super.onActivityCreated(savedInstanceState); prefs = this.getActivity().getSharedPreferences("jmri.enginedriver_preferences", 0); currentValue = prefs.getString("prefThrottleScreenType", this.getActivity().getApplicationContext() .getResources().getString(R.string.prefThrottleScreenTypeDefault)); nameEntries = this.getActivity().getApplicationContext().getResources() .getStringArray(R.array.prefThrottleScreenTypeEntries); nameEntryValues = this.getActivity().getApplicationContext().getResources() .getStringArray(R.array.prefThrottleScreenTypeEntryValues); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_default_name); v.setText(nameEntries[0]); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_simple_name); v.setText(nameEntries[1]); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_vertical_name); v.setText(nameEntries[2]); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_big_left_name); v.setText(nameEntries[3]); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_big_right_name); v.setText(nameEntries[4]); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_vertical_left_name); v.setText(nameEntries[5]); v = (RadioButton) getView().findViewById(R.id.intro_throttle_type_vertical_right_name); v.setText(nameEntries[6]); RadioGroup radioGroup = getView().findViewById(R.id.intro_throttle_type_radio_group); radioGroup.clearCheck(); if (nameEntryValues[0].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_default_name); } else if (nameEntryValues[1].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_simple_name); } else if (nameEntryValues[2].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_vertical_name); } else if (nameEntryValues[3].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_big_left_name); } else if (nameEntryValues[4].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_big_right_name); } else if (nameEntryValues[5].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_vertical_left_name); } else if (nameEntryValues[6].equals(currentValue)) { radioGroup.check(R.id.intro_throttle_type_vertical_right_name); } radioGroup.jumpDrawablesToCurrentState(); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @SuppressLint("ApplySharedPref") @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int Choice = 0; if (checkedId == R.id.intro_throttle_type_default_name) { Choice = 0; } else if (checkedId == R.id.intro_throttle_type_simple_name) { Choice = 1; } else if (checkedId == R.id.intro_throttle_type_vertical_name) { Choice = 2; } else if (checkedId == R.id.intro_throttle_type_big_left_name) { Choice = 3; } else if (checkedId == R.id.intro_throttle_type_big_right_name) { Choice = 4; } else if (checkedId == R.id.intro_throttle_type_vertical_left_name) { Choice = 5; } else if (checkedId == R.id.intro_throttle_type_vertical_right_name) { Choice = 6; } prefs.edit().putString("prefThrottleScreenType", nameEntryValues[Choice]).commit(); } }); }
From source file:com.loadsensing.app.Chart.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chart);/* www .java 2 s . c o m*/ final WebView googleChartView = (WebView) findViewById(R.id.chart); Bundle extras = null; if (savedInstanceState == null) { extras = getIntent().getExtras(); if (extras == null) { SensorSelected = null; } else { SensorSelected = extras.getString("idsensorselected"); Log.d(DEB_TAG, "Xarxa que hem triat anteriorment: " + SensorSelected); } } // Listener para generar el grfico cada vez que se escoge la opcin en // el radiobutton RadioGroup rg = (RadioGroup) findViewById(R.id.tipochart); rg.clearCheck(); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { generaChart(googleChartView, checkedId, SensorSelected); } }); }
From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFilesFragment.java
@Override public void onShow(AlertDialog dialog) { if (dialog != null && getFragmentManager().findFragmentByTag(TAG_PRIORITY_DIALOG) != null) { if (curDir == null) { return; }/* ww w . ja v a 2 s. c om*/ List<Priority> priorities = new ArrayList<>(); for (String name : selectedFiles) { TorrentContentFileTree file = curDir.getChild(name); if (file != null) { priorities.add(file.getPriority()); } } /* * We compare the array with randomly selected priority. * If all elements equals with this priority, set isMixedPriority as true and based on * the random priority choosing radio button, which will be checked by default. * Else, set isMixedPriority as false and clear check in RadioGroup */ Priority randomPriority = priorities.get(new Random().nextInt(priorities.size())); boolean isMixedPriority = false; if (randomPriority == Priority.UNKNOWN) { isMixedPriority = true; } else { for (Priority priority : priorities) { if (randomPriority != priority) { isMixedPriority = true; break; } } } if (!isMixedPriority) { int resId; switch (randomPriority) { case IGNORE: resId = R.id.dialog_priority_low; break; case SEVEN: resId = R.id.dialog_priority_high; break; default: resId = R.id.dialog_priority_normal; } RadioButton button = (RadioButton) dialog.findViewById(resId); if (button != null) { button.setChecked(true); } } else { RadioGroup group = (RadioGroup) dialog.findViewById(R.id.dialog_priorities_group); if (group != null) { group.clearCheck(); } } } }
From source file:com.mycodehurts.rapidmath.app.TestActivity.java
public void onBtnClicked(View v) { if (v.getId() == R.id.btnNextQuestion) { //Store User's answer first RadioGroup chkSex = (RadioGroup) findViewById(R.id.groupAnswers); Question q = lstQuestions.get(iQuestion); q.iUserAnswer = chkSex.indexOfChild(findViewById(chkSex.getCheckedRadioButtonId())); Log.i("JS: ", "Answer: " + q.iAnswer + " Selection: " + q.iUserAnswer); //Increase counter and check if results can be displayed. iQuestion++;/*from w w w. j av a 2 s . c o m*/ if (iQuestion >= 10) { timer.cancel(); timer.purge(); int iPass = 0; String strFailedQ = new String(); for (int i = 0; i < 10; i++) { //Log.i("JS: "," "+lstQuestions.get(i).iUserAnswer + " "+lstQuestions.get(i).iAnswer); if (lstQuestions.get(i).iUserAnswer == lstQuestions.get(i).iAnswer) { iPass++; } else { if (lstQuestions.get(i).iUserAnswer < 0) { strFailedQ += "\n\n Q" + (i + 1) + ". " + lstQuestions.get(i).strQuestion + "\n Your Answer: " + " " + "\n Correct Answer" + lstQuestions.get(i).strChoices[lstQuestions.get(i).iAnswer]; } else { strFailedQ += "\n\n Q" + (i + 1) + ". " + lstQuestions.get(i).strQuestion + "\n Your Answer: " + lstQuestions.get(i).strChoices[lstQuestions.get(i).iUserAnswer] + "\n Correct Answer" + lstQuestions.get(i).strChoices[lstQuestions.get(i).iAnswer]; } } } int iPercent = iPass * 100 / 10; //Load next activity. Intent intent = new Intent(this, ShowResult.class); intent.putExtra("iPercent", iPercent); intent.putExtra("strFailedQ", strFailedQ); //String strTestType = new String(); /*if(iLevel==0) strTestType = "Easy"; else if(iLevel ==1) strTestType = "Medium"; else strTestType = "Hard"; */ intent.putExtra("TestType", strTestType); startActivity(intent); return; } //Fetch next question. NextQuestion(); //Update UI ((TextView) findViewById(R.id.textView2)).setText("Question " + (iQuestion + 1) + " of 10"); chkSex.clearCheck(); } }