Prerequisite

If you not understand this lecture Spinner view in android studio .You should also read my previous lectures. Toggle button in android studio and Radio button using android studio. After reading these lecture you will also able to create Spinner view of your app.

Overview

Spinner is  similar to a drop-down list for selecting items.Spinner provides facility to select a quick option from list. In the default state, a spinner shows its currently selected value. Touching the spinner displays a drop down menu with all other available values.

Introduction

In this lecture will we describe how can create Spinner view in android.We will also describe Spinner view and its description.what is Spinner view. why we can use it .After Reading this lecture you will understand Spinner view in android And i hope you will create Spinner view of your application.

Description of Spinner View

In this lecture we describe how can create a android spinner view example. Android spinner example can help to select one item in a list view. So we create application that demonstrate how can create spinner and also define how can handle click events  in spinner view. First of all you will create a new project in android studio. Every project contain two file first is java class file and second is layout XML file. So your first step is open a layout XML file and add a spinner and set height width. After complete this step you will add text view and also assign id to text view For more detail about spinner view  in android click on spinner view in android.So you will find out the value folder expand this value folder and click on string XML file and add string array of country name  in string XML file. Now I open a string. XML file and paste that code of spinner view in android.

XML Layout 

So we add Spinner view into this layout and set height .

Different property that are used in layout.xml file  explain here

  • warp_content   warp_content means height and width similar to the text that are entered.
  • Match_parent   means height and width similar to parent.
  • Spinner view    Spinner provides facility to select a quick option from list

In this example we are going to create a simple UI that includes only (spinner view in android ) with Different attributes.And paste the following code spinner view in android into layout .XML file.

Now you may open the Graphical layout editor to preview the User Interface you created of spinner view  in android.

Alt Tag spinner view in android

Code that are placed in java class file of Spinner view in android

Run the application of  button Spinner view in android

Alt Tag android spinner list view

When you select option Pakistan in spinner view then output show in below pic

Alt Tag android item select in spinner view 2

When you select option Australia in spinner view then output show in below pic

Alt Tag android item select in spinner view

 

Thank you  for reading this lecture Hope you got the idea.