'How the Exposed Drop-Down Menu can select item based on the option selected?

Can the Exposed Drop-Down Menu be used like spinner to select the option to show the item selected which want to show in the fragment page? Because I cannot find any materials related by using Exposed Drop-Down Menu in fragment to choose item in recyclerview.

Below are my function required show:

Page showed



Solution 1:[1]

I am not sure if I do understand you correctly but if you are looking for a "Material Spinner" you can use a TextInputLayout with the style Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu, and a MaterialAutoCompleteTextView inside the TextInputLayout as the following (the example is inside a ConstraintLayout):

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/spinnerTextInputLayout"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
            android:layout_width="0dp"
            android:hint="Spinner"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

            <com.google.android.material.textfield.MaterialAutoCompleteTextView
                android:id="@+id/autoCompleteTextView"
                style="The style you want"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:inputType="none"/>

        </com.google.android.material.textfield.TextInputLayout>

later on your class you can initialise the TextInputLayour and add a textChangedListener() as the following:

autoCompleteTextView.addTextChangedListener { 
    // trigger your filtering event
 }

I hope it helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MACROSystems