Spinner - Line break in list

Asked

Viewed 161 times

1

When opening the Spinner, has some options that are great, so by default he puts ".." points at the end of the item.

Is there any opção padrão do Spinner for the automatic break or would have to be created a xml de layout for that reason ?

1 answer

0

There is thus no direct option for multi metering without extending the spinner and override and catch certain views.

I think the easiest thing is to create an xml with the layout you want to represent a line and then put that xml as spinner 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 Adapter array and place a list of data with the listed nameDados:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.