Search code examples
javaandroidandroid-arrayadapterandroid-spinner

Getting Problem In Spinner Android Studio


I was making an app. I am trying to add a scrollable spinner in my Android App shown in the given image below. But I have attempted many codes but I failed to get proper results. The main problem is that when I am implementing a spinner in my android app and when I add an adapter in it, it works like a normal dropdown spinner but I have too many items for my spinner and I want someone to scroll when he or she clicks on the spinner.

I want to make spinner like this:=

After trying my code I can't scroll the spinner it was showing normal dropdown items

Please answer if anyone have any solution

In the following image, I can scroll the spinner and select the desired item enter image description here

You can check this image I want to make a same scrollable spinner, Now here is the code which I tried -

<Spinner
        android:id="@+id/test_spinner"
        android:layout_width="50dp"
        android:layout_height="match_parent"
        android:spinnerMode="dropdown"/>

Java --

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.days, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);

Solution

  • The only issue is that you are using editText with spinner and when spinner opens keyboard also open then your spinner items hiding behind the keyboard so solution is just use spinner without editText.