kaveer
2/4/2017 - 6:53 AM

Spinner(drop down list)

Spinner(drop down list)

//in layout

 <Spinner
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/spinnerInsuranceType"
    android:layout_weight="1"
    android:entries="@array/insuranceType"/>
    
//in string.xml

<string-array name="insuranceType">
        <item>Third party</item>
        <item>Premium </item>
    </string-array>

    <string-array name="FitnessRenewalMonth">
        <item>January</item>
        <item>February</item>
        <item>March</item>
        <item>April</item>
        <item>May</item>
        <item>June</item>
        <item>July</item>
        <item>August</item>
        <item>September</item>
        <item>October</item>
        <item>November</item>
        <item>December</item>
    </string-array>

    <string-array name="FitnessDuration">
        <item>6 months</item>
        <item>1 year </item>
        <item>2 year </item>
    </string-array>
 Spinner spinnerInsuranceType;
 
 spinnerInsuranceType = (Spinner)view.findViewById(R.id.spinnerInsuranceType);
 
 TableInsurance.insuranceType = spinnerInsuranceType.getSelectedItem().toString();