1

Here is my XML of the spinner but it did not work.

  <Spinner
        android:id="@+id/frequency"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/spinner_voices"
        android:gravity="center|center_horizontal"
         />
Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
hanif s
  • 488
  • 1
  • 3
  • 19

1 Answers1

2

You need to set your own layout for spinner item.

ArrayAdapter adap = new ArrayAdapter<String>(this, R.layout.spinner_item, new String[]{"ABC", "DEF", "GHI"});
spriner.setAdapter(adap);

Where R.layout.spinner_item is a layout with content:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" 
    android:gravity="center"/>
Chirag
  • 56,621
  • 29
  • 151
  • 198
  • Thnx, but this is text view and i am using the spinner i think, i am new to android plz help – hanif s May 24 '13 at 06:37
  • 1
    First of all create one layout for textview and set into arrayAdapter and then set that adapter in spinner. – Chirag May 24 '13 at 06:39