Java Code Examples for com.google.android.material.button.MaterialButtonToggleGroup#check()
The following examples show how to use
com.google.android.material.button.MaterialButtonToggleGroup#check() .
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: ThemeSwitcherDialogFragment.java From material-components-android with Apache License 2.0 | 5 votes |
private void initializeChooseThemeButtons(View view) { Context context = view.getContext(); ThemePreferencesManager themePreferencesManager = new ThemePreferencesManager(context, resourceProvider); MaterialButtonToggleGroup themeToggleGroup = view.findViewById(R.id.theme_toggle_group); themeToggleGroup.check(themePreferencesManager.getCurrentThemeId()); themeToggleGroup.addOnButtonCheckedListener((group, checkedId, isChecked) -> { if (isChecked) { themePreferencesManager.saveAndApplyTheme(checkedId); } }); }
Example 2
Source File: ContainerTransformConfigurationHelper.java From material-components-android with Apache License 2.0 | 5 votes |
/** Update whether to use arc motion based on the selected radio button */ private void setUpBottomSheetPathMotionButtonGroup(View view) { MaterialButtonToggleGroup toggleGroup = view.findViewById(R.id.path_motion_button_group); if (toggleGroup != null) { // Set initial value. toggleGroup.check(arcMotionEnabled ? R.id.arc_motion_button : R.id.linear_motion_button); toggleGroup.addOnButtonCheckedListener( (group, checkedId, isChecked) -> { if (checkedId == R.id.arc_motion_button) { arcMotionEnabled = isChecked; } }); } }
Example 3
Source File: ContainerTransformConfigurationHelper.java From material-components-android with Apache License 2.0 | 5 votes |
/** Update the fade mode based on the selected radio button */ private void setUpBottomSheetFadeModeButtonGroup(View view) { MaterialButtonToggleGroup toggleGroup = view.findViewById(R.id.fade_mode_button_group); if (toggleGroup != null) { // Set initial value. toggleGroup.check(fadeModeButtonId); toggleGroup.addOnButtonCheckedListener( (group, checkedId, isChecked) -> { if (isChecked) { fadeModeButtonId = checkedId; } }); } }
Example 4
Source File: TimePickerMainDemoFragment.java From material-components-android with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("deprecation") // requireFragmentManager() public View onCreateDemoView( LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { ViewGroup view = (ViewGroup) layoutInflater.inflate(R.layout.time_picker_main_demo, viewGroup, false); Button button = view.findViewById(R.id.timepicker_button); textView = view.findViewById(R.id.timepicker_time); MaterialButtonToggleGroup timeFormatToggle = view.findViewById(R.id.time_format_toggle); clockFormat = TimeFormat.CLOCK_12H; timeFormatToggle.check(R.id.time_format_12h); timeFormatToggle.addOnButtonCheckedListener( (group, checkedId, isChecked) -> { boolean isSystem24Hour = DateFormat.is24HourFormat(getContext()); boolean is24Hour = checkedId == R.id.time_format_24h || (checkedId == R.id.time_format_system && isSystem24Hour); clockFormat = is24Hour ? TimeFormat.CLOCK_24H : TimeFormat.CLOCK_12H; }); SwitchCompat frameworkSwitch = view.findViewById(R.id.framework_switch); button.setOnClickListener(v -> { if (frameworkSwitch.isChecked()) { showFrameworkTimepicker(); return; } TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(); timePickerDialog.show(requireFragmentManager(), "fragment_tag"); timePickerDialog.setTimeFormat(clockFormat); timePickerDialog.setHour(hour); timePickerDialog.setMinute(minute); timePickerDialog.setListener(dialog -> { int newHour = dialog.getHour(); int newMinute = dialog.getMinute(); TimePickerMainDemoFragment.this.onTimeSet(newHour, newMinute); }); }); return view; }