get Spinner Adapter from String array - Android android.widget

Android examples for android.widget:Adapter

Description

get Spinner Adapter from String array

Demo Code

import android.content.Context;
import android.widget.ArrayAdapter;

public class Main{

    public static ArrayAdapter<String> getSpinnerAdapter(Context context,
            String[] datas) {/*from   w  ww . j a  v  a2 s.c  o  m*/
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
                android.R.layout.simple_spinner_item, datas);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        return adapter;
    }

}

Related Tutorials