select Item in Spinner - Android User Interface

Android examples for User Interface:Spinner

Description

select Item in Spinner

Demo Code


import android.app.Activity;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class Main{
    public static void selectItem(Spinner spinner, Object item) {
        for (int index = 0; index < spinner.getCount(); ++index) {
            if (spinner.getItemAtPosition(index).equals(item)) {
                spinner.setSelection(index);
            }/*from  ww w. j ava  2  s . c  o m*/
        }
    }
}

Related Tutorials