mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
[Chip] Update chipgroup demo to include switch to toggle the requiredSelection attr.
PiperOrigin-RevId: 324015228
This commit is contained in:
parent
84fd465cea
commit
4b01ac4b22
@ -34,6 +34,7 @@ import io.material.catalog.feature.DemoFragment;
|
||||
public class ChipGroupDemoFragment extends DemoFragment {
|
||||
|
||||
private SwitchMaterial singleSelectionSwitch;
|
||||
private SwitchMaterial selectionRequiredSwitch;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@ -42,6 +43,8 @@ public class ChipGroupDemoFragment extends DemoFragment {
|
||||
View view = layoutInflater.inflate(getChipGroupContent(), viewGroup, false /* attachToRoot */);
|
||||
|
||||
singleSelectionSwitch = view.findViewById(R.id.single_selection);
|
||||
selectionRequiredSwitch = view.findViewById(R.id.selection_required);
|
||||
|
||||
ChipGroup reflowGroup = view.findViewById(R.id.reflow_group);
|
||||
ChipGroup scrollGroup = view.findViewById(R.id.scroll_group);
|
||||
|
||||
@ -53,6 +56,16 @@ public class ChipGroupDemoFragment extends DemoFragment {
|
||||
initChipGroup(reflowGroup);
|
||||
initChipGroup(scrollGroup);
|
||||
});
|
||||
|
||||
selectionRequiredSwitch.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
reflowGroup.setSelectionRequired(isChecked);
|
||||
scrollGroup.setSelectionRequired(isChecked);
|
||||
|
||||
initChipGroup(reflowGroup);
|
||||
initChipGroup(scrollGroup);
|
||||
});
|
||||
|
||||
initChipGroup(reflowGroup);
|
||||
initChipGroup(scrollGroup);
|
||||
|
||||
|
||||
@ -29,7 +29,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cat_chip_group_single_selection_text"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/selection_required"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cat_chip_group_selection_required_text"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/cat_chip_group_refresh"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
|
||||
<string name="cat_chip_group_demo_title">Chip Group Demo</string>
|
||||
<string name="cat_chip_group_single_selection_text">Single selection</string>
|
||||
<string name="cat_chip_group_selection_required_text">Selection required</string>
|
||||
|
||||
<string name="cat_chip_reflow_group">Reflowing chip group</string>
|
||||
<string name="cat_chip_scroll_group">Scrolling chip group</string>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user