1. Introduction

Spinner with a icon and text, can be much more easier in terms of  giving options to the user, i.e., when there is a option to select with an icon it will be much more easier for user to select i.e., in terms of a hotel menu where showing image of tiffin with its image to the left.

Previously I have made a tutorial on spinner where i have just used text in spinner.But now in this tutorial i have made a spinner which will have a icon in it.

 

Android Tutorial on Spinner

 

2. Creating activity_main.xml

 

Now we need to add a spinner to the activity file and then it can be further designed.

 

 

3. Creating row.xml file

 

Next we need to design this spinner accordingly i.e., we require icon to be there before text.

Add a imageview and textview as

 

 

4. Creating MainActivity.java file

 

Add data to the spinner here i have given mobile operating systems data to spinner using a String Array.

 

 

Then initialize the spinner and also adapter.

 

 

 

Set the adapter so that data will be shown in the spinner

 

 

 

Output :

spin1

 

spin2

Show Buttons
Hide Buttons
Read previous post:
Android Sending an Email Through Your App

Close