Try popular Android Application by Feliz-Droid

Try popular Android Application by Feliz-Droid

Speaking Caller logo
Speaking Caller
   
Battery temperature logo
Battery Temperature
   
Dual Photo logo
Dual Photo
   
Ganesh Wallpapersl ogo
Lord Ganesh Wallpaper
   
Girly Pink Keyboard l ogo
Girly Pink Keyboard

Thursday, September 22, 2011

show multiline text inside spinner

Dear all.

To show multiline text inside the spinner follow few steps below and get working.

Step 1: Create a new Layout file name as textview.xml. and overwrite the code with below  one.


<?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"></TextView>

Step 2: After that save this file and open the code file (.java)  file where spinner is used. If 
you have used Array Adapter to fill spinner. Then just write below code instead of that.

      ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.plans,     R.layout.textview);
        spinnername.setAdapter(adapter);


In above code, R.array.plans is the string array which i have used to fill spinner. I you have to fill spinner from the database then just try below code.

adapter = new ArrayAdapter<String>(this,android.R.layout.textview,aLst);

adapter.setDropDownViewResource(R.layout.textview);
spinnername.setAdapter(adapter);  
 
Now you have done with. Enjoy it.
 
Thanks...... 


   

9 comments: