Skip to main content

Posts

Showing posts with the label spinner example

Custom Spinner in Android

Custom Spinner in Android/Spinner using custom adapter/spinner with icon and text  In this tutorial, i'll show you to customizing spinner in different methods.  To change the normal display of spinner view, add background image using the code " android:background="@drawable/myspinner_background" in the xml. You can also make it customizable by setting up an xml file in drawable folder Custom display with icon in the spinner   main.xml <? xml version = "1.0" encoding = "utf-8" ?> < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"     android:orientation = "vertical"     android:layout_width = "fill_parent"     android:layout_height = "fill_parent"     >     < Spinner     android:drawSelectorOnTop = "true"     android:id = "@+id/spinner1"     android:layout_width = "match_parent"     android:layout_height = "wrap_content&

Spinner in Android/Spinner Example/Simple Spinner Program

Spinner in Android/Spinner Example/Simple Spinner Program Spinner is a widget similar to a drop-down list for selecting items .  Create an array of items to be  displayed String androidphones []={ "Sony Ericson Xperia" , "Motorola Droid" , "Samsung Galaxy" , "HTC Sensation" , "LG Nitro" , "Google Nexus" }; Add an array adapter to display the spinner spinner .setAdapter( new ArrayAdapter<String>( this , android.R.layout. simple_spinner_item , androidphones )); In spite of android.R.layout. simple_spinner_item , you can also add android.R.layout.simple_spinner_dropdown_item                           or android.R.layout.simple_dropdown_item_1line Source code main.xml <? xml version = "1.0" encoding = "utf-8" ?> < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"     android:orientation = "vertical"     android:layout_width = "fill_