How to create custom layout for your spinner in ANDROID? or Customizable spinner

By | February 20, 2011

This code helps you to customize the spinner in ANDROID.

For that you have to create an XML file inside your layout folder as shown below and name it spinner.xml.
You can give all properties that are available for TextView inside this which is going to be then applied for your spinner.


TextView>

Now I will show you how to add it to a spinner.

ArrayAdapter my_Adapter = new ArrayAdapter(this, R.layout.spinner,my_array);
My_spinner.setAdapter(my_Adapter);

“my_array” is an array that populates the spinner and “My_spinner” is the spinner.

Please leave your valuable comments if this post was useful…..

Leave a Reply

Your email address will not be published. Required fields are marked *