<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.abbu.spinner_select.MainActivity">
<TextView
android:text="Select one Country : "
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
/>
<Spinner
android:id="@+id/spinner1"
android:entries="@array/country_names"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" />
</RelativeLayout>
FileName: strings.xml
<resources>
<string name="app_name">Spinner_Select</string>
<string-array name="country_names">
<item>India</item>
<item>Pakistan</item>
<item>China</item>
<item>Nepal</item>
<item>Bangladesh</item>
<item>Bhutan</item>
</string-array>
</resources>
Output:
By default, India is the selected spinner item and toast named India will appear.
|
Spinner & Toast Usage in Android |
Now, we'll select any one country:
|
Spinner & Toast Usage in Android |
Finally, I selected Bhutan and a toast named Bhutan will appear.
|
Spinner & Toast Usage in Android |
It is very useful post. Thanks for sharing with us.
ReplyDeletePopup builder Plugin
Your blog on reading is so full of great insights. I love your idea of adapting trade books. We have some that have far too much text, that would be fabulous, modified for our seven-year-old reader.
ReplyDeleteTop IT Service in India