0

Hi I should implement a filter in a recyclerview graphically I wanted to introduce such a thing but what element is it? a spinner? if yes how can i make it similar to this play store example thank you

menu

options menu to filter items

Elax46
  • 23
  • 2
  • I think this is what you are looking for: https://material.io/components/radio-buttons – F.Mysir Jul 08 '22 at 10:10
  • Single choice alert dialog https://stackoverflow.com/questions/5660887/how-to-select-a-entry-in-alertdialog-with-single-choice-checkbox-android – Gobu CSG Jul 08 '22 at 10:34

1 Answers1

0

Radio buttons example

API and source code:

MaterialRadioButton RadioGroup

The following example shows a radio button group with five radio buttons.

enter image description here

In the layout:

<RadioGroup
    android:id="@+id/radioGroup"
    android:checkedButton="@+id/radio_button_1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <RadioButton
        android:id="@+id/radio_button_1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/label_1"/>
    <RadioButton
        android:id="@+id/radio_button_2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/label_2"/>
    <RadioButton
        android:id="@+id/radio_button_3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/label_3"/>
    <RadioButton
        android:id="@+id/radio_button_4"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/label_4"/>
    <RadioButton
        android:id="@+id/radio_button_5"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:enabled="false"
        android:text="@string/label_5"/>
</RadioGroup>

In code:

val checkedRadioButtonId = radioGroup.checkedRadioButtonId // Returns View.NO_ID if nothing is checked.
radioGroup.setOnCheckedChangeListener { group, checkedId ->
    // Responds to child RadioButton checked/unchecked
}

// To check a radio button
radioButton.isChecked = true

// To listen for a radio button's checked/unchecked state changes
radioButton.setOnCheckedChangeListener { buttonView, isChecked
    // Responds to radio button being checked/unchecked
}

Happy Coding :)

Kishan Mevada
  • 662
  • 1
  • 6
  • 17