0

I have a spinner defined in a GridLayout like this -

     <GridLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="visible"
        android:layout_column="0"
        android:layout_row="0"
        android:columnCount="2"
        android:rowCount="4"
        android:background="@color/colorPrimary"
        android:id="@+id/gl">

        <android.support.v7.widget.AppCompatTextView
            android:layout_column="0"
            android:layout_row="1"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"
            android:text="Language"
            android:textColor="@android:color/white"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <Spinner
            android:id="@+id/lang_spinner"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_column="1"
            android:layout_row="1"
            android:layout_columnWeight="3"
            android:layout_rowWeight="1"/>  
    </GridLayout>

And the adapter code is -

    ArrayList<String> langList = new ArrayList<>();

    for (String loc : readerVm.getAvailableLanguages())
    {
        if (!langList.contains(loc))
        {
            langList.add(loc);
        }
    }
    Collections.sort(langList);
    ArrayAdapter<String> langSpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, langList);
    langSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    langSpinner.setAdapter(langSpinnerArrayAdapter);

When the text in the lang_spinner is small enough to be displayed entirely on the screen it's good enough, but when the text gets larger and goes beyond the screen I was expecting it to get truncated but somehow the lang_spinner vanishes and all the items in Column 1. First I thought maybe this is because of the GridLayout but I also tried with putting the spinner in linear layout and that being the top most layout of the activity and still the spinner vanished on longer texts.

I also tried using custom spinner layout but with same result. At this point I have no clue of what's going wrong.

halfer
  • 19,824
  • 17
  • 99
  • 186
ac-lap
  • 1,623
  • 2
  • 15
  • 27
  • Are you looking for this?>> http://stackoverflow.com/questions/14139106/spinner-does-not-wrap-text-is-this-an-android-bug – Vivek Solanki Dec 30 '16 at 18:10
  • No, in the link the problem is text getting truncated but in my case somehow the spinner control is getting vanished! – ac-lap Dec 30 '16 at 18:15
  • @ac-lab are you using a custom `ArrayAdapter` class? Can you share the code if you are. – Pztar Dec 30 '16 at 18:19
  • @Pztar No, I am not using custom adapter. I have still updated the post with adapter code. – ac-lap Dec 30 '16 at 18:33

0 Answers0