List of usage examples for android.widget RadioGroup jumpDrawablesToCurrentState
@Override public void jumpDrawablesToCurrentState()
From source file:jmri.enginedriver.intro_buttons.java
@SuppressWarnings("ConstantConditions") @Override/* www .j a va2s.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//from w w w.ja v a 2s . c o m 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//ww w . j a v a 2 s. c o 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(); } }); }