• Top Posts

    Spinner Example android

    Spinner : 
    Spinner is drop-down menu it displays all list values

    in this example we are displaying data from String resource file.



    Step-1:  Create sample project and add spinner on XML .



    <android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.apps.mallem.androidapps.spinner.Spinner">

    <Spinner
    android:entries="@array/String_array_name"
    android:id="@+id/spinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    </Spinner>

    </android.support.constraint.ConstraintLayout>




    Step -2 : Add values on Strings resource file.

    <resources>
    <string name="app_name">AndroidApps</string>
    <string-array name="String_array_name">
    <item>Value 1</item>
    <item>Value 1</item>
    <item>Value 1</item>
    <item>Value 1</item>

    </string-array>
    </resources>
    just Run the app result will be dispalys 
    Thanks Friends.  :)












    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728