Spinner - List line break

1

When you open Spinner , you have some options that are large, so by default it places ".." points at the end of the item.

Is there a% of% for wrapping or would a opção padrão do Spinner be created for this?

    
asked by anonymous 25.01.2018 / 17:34

1 answer

0

There's no direct way to multi-line without extending the spinner and override and catch certain views.

I think the easiest is to create an xml with the layout you want to represent a line and then put that xml as the spinner's adapter.

spinner_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
   android:text="@+id/TextView01" 
   android:id="@+id/TextView01"
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
   android:textSize="17sp"/>

Then you create the array adapter and put a list of data there with the name listData:

ArrayAdapter dataAdapter = new ArrayAdapter<String>(getActivity(), R.layout.spinner_item, listaDeDados);
adapter.setDropDownViewResource(R.layout.spinner_item);
spinner.setAdapter(adapter);  
    
25.01.2018 / 17:46