# 2021-05-29-Android-DropDown

![Preview Image](https://1950244352-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LmODHLAXCUmZPGgxgxk%2Fsync%2Fb96f0f65982ee0eb89dcee9edf9d181aaccc9342.png?generation=1622304458865483\&alt=media) ![Preview Image](https://1950244352-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LmODHLAXCUmZPGgxgxk%2Fsync%2F40378b3d1aa521a91e35044d74b7a1f874e934a9.png?generation=1622304458920652\&alt=media)

```markup
<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="10dp"
    android:layout_weight="1"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
    app:startIconDrawable="@drawable/ic_baseline_calendar_today_24">

    <com.google.android.material.textfield.MaterialAutoCompleteTextView
        android:id="@+id/expMonthFieldEditCard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/expiration_month"
        android:imeOptions="actionNext|actionPrevious"
        android:maxLines="1"
        android:inputType="none"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</com.google.android.material.textfield.TextInputLayout>
```

Now, add following to your fragment / activity file.

```kotlin
val monthsAdapter = ArrayAdapter(
    requireContext(),
    android.R.layout.simple_spinner_item, 
    ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]
)
binding.expMonthFieldEditCard.setAdapter(monthsAdapter)

// to force show all options / suggestions
monthsAdapter.filter.filter(null)
binding.expMonthFieldEditCard.setOnClickListener {
    monthsAdapter.filter.filter(null)
}
```
