android - Spinner with image and text -


i want spinner enter image description here

only topmost header should have image , text. remaining drop down should have text only. can me in making this.

i have tried this..

i xml file

 <spinner android:id="@+id/spinner1"  android:layout_width="200dp"  android:layout_height="50dp"  android:layout_alignparentleft="true"  android:layout_below="@id/view"  android:layout_marginleft="35dp"  android:layout_margintop="20dp"  android:background="@drawable/grey_btn"  android:popupbackground="@drawable/drop_down_background"  android:spinnermode="dropdown" /> 

and

arrayadapter<string> adapter1 = new arrayadapter<string>(mcontext, r.drawable.spinner_text,r.id.customtextview,arr1); adapter1.setdropdownviewresource(r.drawable.drop_down); s1.setadapter(adapter1); 

you should have both getview , getdropdownview in adapter. in way specify different looks on selected item , rest of list.

in getview:

textview = (textview) convertview.findviewbyid(r.id.spinner_item_text); imageview = (imageview) convertview.findviewbyid(r.id.spinner_item_image); textview.setvisibility(imageview.visible); imageview.setvisibility(imageview.visible); 

in getdropdownview:

textview = (textview) convertview.findviewbyid(r.id.spinner_item_text); imageview = (imageview) convertview.findviewbyid(r.id.spinner_item_image); textview.setvisibility(imageview.visible); imageview.setvisibility(imageview.invisible); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -