create ArrayAdapter for Spinner - Android java.lang

Android examples for java.lang:Array Element

Description

create ArrayAdapter for Spinner

Demo Code


//package com.java2s;
import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class Main {
    public static ArrayAdapter<String> createArrayAdapter(Context ctx,
            Spinner spinner) {//from  w  w w.ja  va  2s  .c o  m

        ArrayAdapter arrayAdapter = new ArrayAdapter<String>(ctx,
                android.R.layout.simple_spinner_item);
        arrayAdapter
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        spinner.setAdapter(arrayAdapter);

        return arrayAdapter;
    }
}

Related Tutorials