Material-components-android: Unable to find Spinner (Select Dropdown)

Created on 21 Nov 2018  路  5Comments  路  Source: material-components/material-components-android

A Spinner for Android with Design similar to Floating Input Layout https://material.io/design/components/text-fields.html

Like this for Web: https://material-components.github.io/material-components-web-catalog/#/component/select

Spinner should be provided.

Most helpful comment

This is available now in 1.1.0-alpha06 via Exposed Dropdown Menus that are based on TextInputLayout!

All 5 comments

This is available now in 1.1.0-alpha06 via Exposed Dropdown Menus that are based on TextInputLayout!

To make the dropdown not editable the documentation suggests you set android:editable="false" on the AutoCompleteTextView. Android Studio sais it's deprecated and the app crashes when inflating the XML. I'm using com.google.android.material:material:1.1.0-alpha07. I don't want the user to be only able to select one of the entries in the dropdown. Not type something into the textbox.

Specifically Android studio tells me android:editable is deprecated: Use an <EditText> to make it editable witch makes no sence. I don't want to make it editable quite the contrary.


As a workaround I now put

my_dropdown.keyListener = null

in the onCreate where I also set the adapter. Setting the keyListener of the AutoCompleteTextView to null makes you unable to type anything.
This is kotlin code, but I'm sure you can figure out the matching Java code if you use java.

@shiomax See #465 for notes on deprecation warning

I'm sorry to be so blunt, but: This implementation is a joke, right?
Why the hell would you not use the native Spinner component? This implementation is useless for any serious use case 馃槥

Short comings:

  • No way to have different layouts for drop down / selected item. Selected item just used "toString" on the item of the adapter...
  • No item selected callback with original model - just a "on text change", what if you have items with the same text? Did no one think of this?
  • Recommended way of preventing text input does not work (android:inputType="none")

and everything mentioned here: https://blog.usejournal.com/there-is-no-material-design-spinner-for-android-3261b7c77da8

I seriously hope you reconsider the current implementation.

Was this page helpful?
0 / 5 - 0 ratings