This is my code and I can not get the items add inside Spinner. I don't know what's going wrong, and unable to find any other way!
Java:
spinner = (Spinner)getView().findViewById(R.id.spinner);
String[] datos = getResources().getStringArray(R.array.items);
ArrayAdapter<String> adaptador = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_spinner_item, datos);
adaptador.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adaptador);
XML:
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_margin="26dp"
android:textColor="#FFF"/>
strings.xml:
<string-array name="items">
<item >Item 1</item>
<item >Item 2</item>
<item >Item 3</item>
<item >Item 4</item>
</string-array>
Thanks in advance for the help.
In my case just added some padding in the XML file.
Try This XML Only
Remove Below From Acticity
on selected item
before that ..
your spinner text color is white: change it to other color.
also you can directly access the array resource in your layout. Like:
EDIT
you can try using a custom layout for your spinner item:
use the layout using:
here
R.layout.spinner_item
is the spinner custom layout