Example usage for android.widget ArrayAdapter ArrayAdapter

List of usage examples for android.widget ArrayAdapter ArrayAdapter

Introduction

In this page you can find the example usage for android.widget ArrayAdapter ArrayAdapter.

Prototype

public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects) 

Source Link

Document

Constructor

Usage

From source file:gr.scify.newsum.ui.SearchViewActivity.java

private void initTopicSpinner() {
    // Get topics in category. Null accepts all user sources. Modify
    // according to user selection
    final String[] saTopicIDs = SearchTopicActivity.saTopicIDs;
    final String[] saTitles = SearchTopicActivity.saTopicTitles;
    final String[] saDates = SearchTopicActivity.saTopicDates;
    // TODO add TopicInfo for SearchResults as well and parse accordingly

    // final String[] saTopicIDs = extras.getStringArray("searchresults");
    final TextView title = (TextView) findViewById(R.id.title);
    // Fill topic spinner
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            android.R.layout.simple_spinner_item, saTitles);

    final TextView tx = (TextView) findViewById(R.id.textView1);
    // tx.setMovementMethod(LinkMovementMethod.getInstance());
    //      final float minm = tx.getTextSize();
    //      final float maxm = (minm + 24);

    // create an invisible spinner just to control the summaries of the
    // category (i will use it later on Swipe)
    Spinner spinner = (Spinner) findViewById(R.id.spinner1);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*  w  w  w  . j ava 2  s . co m*/

    // Scroll view init
    final ScrollView scroll = (ScrollView) findViewById(R.id.scrollView1);
    // Add selection event
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            // Show waiting dialog
            showWaitingDialog();

            // Changing summary
            loading = true;
            // Update visibility of rating bar
            final RatingBar rb = (RatingBar) findViewById(R.id.ratingBar);
            rb.setRating(0.0f);
            rb.setVisibility(View.VISIBLE);
            final TextView rateLbl = (TextView) findViewById(R.id.rateLbl);
            rateLbl.setVisibility(View.VISIBLE);

            scroll.scrollTo(0, 0);
            //            String[] saTopicIDs = sTopicIds.split(sSeparator);

            SharedPreferences settings = getSharedPreferences("urls", 0);
            // get user settings for sources
            String UserSources = settings.getString("UserLinks", "All");
            String[] Summary = NewSumServiceClient.getSummary(saTopicIDs[arg2], UserSources);
            if (Summary.length == 0) { // WORK. Updated: CHECK
                // Close waiting dialog
                closeWaitingDialog();

                AlertDialog.Builder alert = new AlertDialog.Builder(SearchViewActivity.this);
                alert.setMessage(R.string.shouldReloadSummaries);
                alert.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface arg0, int arg1) {
                        startActivity(new Intent(getApplicationContext(), NewSumUiActivity.class)
                                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
                    }
                });
                alert.setCancelable(false);
                alert.show();
                loading = false;
                return;
            }
            // track summary views per Search and topic title
            if (getAnalyticsPref()) {
                EasyTracker.getTracker().sendEvent(VIEW_SUMMARY_ACTION, "From Search",
                        saTitles[arg2] + ": " + saDates[arg2], 0l);
            }
            // Generate summary text
            sText = ViewActivity.generateSummaryText(Summary, SearchViewActivity.this);
            pText = ViewActivity.generatesummarypost(Summary, SearchViewActivity.this);
            tx.setText(Html.fromHtml(sText));
            tx.setMovementMethod(LinkMovementMethod.getInstance());
            title.setText(saTitles[arg2] + ": " + saDates[arg2]);
            float defSize = tx.getTextSize();
            SharedPreferences usersize = getSharedPreferences("textS", 0);
            float newSize = usersize.getFloat("size", defSize);
            tx.setTextSize(TypedValue.COMPLEX_UNIT_PX, newSize);
            // update the TopicActivity with viewed item
            TopicActivity.addVisitedTopicID(saTopicIDs[arg2]);

            // Close waiting dialog
            closeWaitingDialog();

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }

    });

}

From source file:fr.mdk.kisspush.KISSPush.java

private void getAliases() {
    kiss_push_cli.get_alias(new KISSPushClient.Callback<ArrayList<String>>() {

        @Override/*from   w w w .  j a  v  a  2 s . co m*/
        public void callback(ArrayList<String> t) {
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
                    android.R.layout.simple_list_item_1, t);

            mDisplay.setAdapter(adapter);
        }
    });
}

From source file:fm.libre.droid.LibreDroid.java

public void addStation() {
    final EditText stationEntry = (EditText) findViewById(R.id.stationEntry);
    stations.add(0, stationEntry.getText().toString());
    try {//from   ww  w .  j a  v a 2  s .  c om
        FileOutputStream stationFile = openFileOutput("libredroid-custom-stations.conf", Context.MODE_PRIVATE);
        for (String station : stations) {
            stationFile.write(station.getBytes());
            stationFile.write('\n');
        }
        stationFile.close();
    } catch (IOException ex) {
        Log.w("libredroid", ex.getMessage());
    }
    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, stations));
    this.prevPage();
}

From source file:com.todotxt.todotxttouch.util.Util.java

public static ArrayAdapter<String> newSpinnerAdapter(Context cxt, List<String> items) {
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(cxt, android.R.layout.simple_spinner_item, items);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    return adapter;
}

From source file:net.palacesoft.cngstation.client.StationActivity.java

public void setCountries(List<String> countriesList) {
    if (!countriesList.isEmpty()) {
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, simple_spinner_item, countriesList);
        dataAdapter.setDropDownViewResource(simple_spinner_dropdown_item);
        countries.setAdapter(dataAdapter);

        if (currentLocationAddress != null) {
            String country = currentLocationAddress.getCountryName();
            int countryIndex = countriesList.indexOf(country);
            if (countryIndex > -1) {
                countries.setSelection(countryIndex);
            }//from   ww w.  j av  a  2 s.  c  o m
        }
    } else {
        showInfoMessage("Could not load country list");
    }
}

From source file:abanyu.transphone.taxi.controller.LoginController.java

public void makeListView(List<String> listElems) {
    String arr[];//from ww  w  .j av  a 2  s  .c o  m
    arr = new String[listElems.size()];

    for (int idx = 0; idx < listElems.size(); idx++) {
        String elem = listElems.get(idx);
        arr[idx] = elem;
    }

    loginMVC.getLoginView()
            .setListAdapter(new ArrayAdapter<String>(loginMVC.getLoginView(), R.layout.listnode, arr));
    ListView listView = loginMVC.getLoginView().getListView();
    listView.setTextFilterEnabled(true);

    listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            itemClicked = ((TextView) view).getText().toString();

            if (thisMode == JSONMode.GET)
                setLoginDataIDs();
            else
                getServerData(); //dont have anything to set
        }
    });
}

From source file:course1778.mobileapp.safeMedicare.Main.FamMemFrag.java

private void add() {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View addView = inflater.inflate(R.layout.add_edit, null);
    //AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(getContext(), R.style.AlertDialogCustom));

    builder.setTitle(R.string.add_title).setView(addView).setPositiveButton(R.string.ok, this)
            .setNegativeButton(R.string.cancel, null).show();

    Spinner spin = (Spinner) addView.findViewById(R.id.spinner);
    //spin.setOnItemSelectedListener(FamMemActivity.getContext());
    ArrayAdapter<String> aa = new ArrayAdapter<String>(FamMemActivity.getContext(), R.layout.spinner_item_text,
            items);// w  w  w  . j  ava  2 s  .  c om
    aa.setDropDownViewResource(R.layout.spinner_dropdown_item);
    spin.setAdapter(aa);

    // field for user adding medication name
    textView = (AutoCompleteTextView) addView.findViewById(R.id.title);

    /** sheet 1 displays all the drug interactions;
     * sheet 2 displays the list of all drugs
      */
    crsList = med_list.rawQuery("SELECT * FROM Sheet1", null);
    crsInteractions = med_interaction.rawQuery("SELECT * FROM DrugDrug", null);

    String[] array = new String[crsList.getCount()];
    int i = 0;
    while (crsList.moveToNext()) {
        String uname = crsList.getString(crsList.getColumnIndex("Name"));
        array[i] = uname;
        i++;
    }

    // Create the adapter and set it to the AutoCompleteTextView
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(FamMemActivity.getContext(), R.layout.listlayout,
            R.id.listTextView, array);
    textView.setAdapter(adapter);

}

From source file:mx.itdurango.rober.siitdocentes.ActivityAlumnos.java

/**
 * Permite descomponer el cdigo html que se enva con una estructura especifica para llenar los datos de la vista
 *
 * @param html cdigo html que se recibi de una peticin HttpGet, debe tener una estructura similar a la siguiente para que el proceso funcione correctamente
 *             <p/>// w w w.ja  v  a2 s.c  o m
 *             <input name="periodo" type="hidden" value="20141" />
 *             <input name="materia" type="hidden" value="SD2424" />
 *             <input name="grupo" type="hidden" value="5VR" />
 *             <input name="docente" type="hidden" value="LOQR841213822" />
 *             <input name="fecha_captura" type="hidden" value="2014/06/12" />
 *             <table>
 *             <tr>
 *             <td>No</td>
 *             <td>Noctrl</td>
 *             <td>Nombre</td>
 *             <td>Unidad 1</td>
 *             <td>Unidad 1</td>
 *             <td>Unidad 3</td>
 *             <td>...</td>
 *             <td>Unidad N</td>
 *             </tr>
 *             <tr>
 *             <td>1</td>
 *             <td>9999999</td>
 *             <td>XXXXXXXXXXXXXXXXXXXXX</td>
 *             <td><input type="text" name="calif[1][1]" value="999"/></td>
 *             <td><input type="text" name="calif[1][2]" value="999"/></td>
 *             <td><input type="text" name="calif[1][3]" value="999"/></td>
 *             <td>...</td>
 *             <td><input type="text" name="calif[1][N]" value="999"/></td>
 *             </tr>
 *             <tr>
 *             <td>2</td>
 *             <td>888888888</td>
 *             <td>YYYYYYYYYYYYYYYYYYYYY</td>
 *             <td><input type="text" name="calif[2][1]" value="999"/></td>
 *             <td><input type="text" name="calif[2][2]" value="999"/></td>
 *             <td><input type="text" name="calif[2][3]" value="999"/></td>
 *             <td>...</td>
 *             <td><input type="text" name="calif[2][N]" value="999"/></td>
 *             </tr>
 *             <tr>
 *             <td>M</td>
 *             <td>000000000</td>
 *             <td>ZZZZZZZZZZZZZZZZZZZZZZ</td>
 *             <td><input type="text" name="calif[M][1]" value="999"/></td>
 *             <td><input type="text" name="calif[M][2]" value="999"/></td>
 *             <td><input type="text" name="calif[M][3]" value="999"/></td>
 *             <td>...</td>
 *             <td><input type="text" name="calif[M][N]" value="999"/></td>
 *             </tr>
 *             </table>
 */
void llenaAlumnos(String html) {
    //Generar un archivo de documento para almacenar los datos del html de forma que se pueda
    //manipular facilmente usando la librera Jsoup
    Document doc = Jsoup.parse(html);

    try {
        //extraer los valores de los elementos del formulario y almacenarlos en los atributos correspondientes de la clase
        Elements e = doc.getElementsByAttributeValue("name", "periodo");
        periodo = e.get(0).attr("value");
        e = doc.getElementsByAttributeValue("name", "materia");
        materia = e.get(0).attr("value");
        e = doc.getElementsByAttributeValue("name", "grupo");
        grupo = e.get(0).attr("value");
        e = doc.getElementsByAttributeValue("name", "docente");
        docente = e.get(0).attr("value");
        e = doc.getElementsByAttributeValue("name", "fecha_captura");
        fecha_captura = e.get(0).attr("value");

        //extraer la tabla correspondiente al listado de alumnos en el caso del siit.itdurango.edu.mx,
        // corresponde a la tabla numero 2 y ya que la numeracin comienza en 0, la tabla que necesitamos est en el indice 1
        Element tabla = doc.getElementsByTag("table").get(1);
        //Extraer todos los elementos de tipo tr que pertenecen a la tabla y almacenarlos en una coleccion de tipo Elements.
        Elements renglones = tabla.getElementsByTag("tr");
        //Recorrer la coleccin de renglones y almacenar cada uno en un objeto
        for (Element tr : renglones) {
            //para cada objeto tr, extraer sus elementos td y almacenarlos en una coleccion
            Elements tds = tr.getElementsByTag("td");
            //permite llevar el control de la columna que se est leyendo, ya que las columnas no tienen un id o clase, se realiza el proceso a mano.
            int col = 1;
            //contenedor de tipo AlumosParciales para almacenar la informacin de cada alumno (tr)
            AlumnosParciales c = new AlumnosParciales();
            for (Element td : tds) {
                if (col == 1) {// la columna 1 corresponde al nmero consecutivo de la tabla
                    c.setNum(td.html());
                } else if (col == 2) {// la columna 2 corresponde al nmero de control del alumno
                    c.setControl(td.html());
                } else if (col == 3) {// la columna 3 corresponde al nombre del alumno
                    c.setNombre(Estaticos.sanitize(td.html()));
                } else { //el resto de las columnas pertenecen a las calificaciones parciales
                    //se extrae el elemento <input> de la columna y se obtiene el atributo valor para recuperar la calificacin en caso de que ya hubiera sido asignada
                    String cal = td.getElementsByTag("input").get(0).attr("value");

                    ArrayList<String> calif = c.getCalificaciones();
                    calif.add(cal);
                    //se agrega la nueva calificacin al conjunto de calificaciones del alumno
                    c.setCalificaciones(calif);
                }
                col++; //incrementa el numero de columa
            }
            if (c.getCalificaciones().size() > 0) { //para evitar agregar al listado de alumnos el encabezado de la tabla, validamos que existan calificaciones.
                gcs.add(c);
            }
        }

        //Llenamos el spinner de unidades a partir del numero de calificaciones que existen en el arreglo
        List<String> spinnerArray = new ArrayList<String>();
        for (int i = 1; i <= gcs.get(1).getCalificaciones().size() - 1; i++) {
            spinnerArray.add("Unidad " + i);
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
                spinnerArray);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spn_unidad.setAdapter(adapter);

        //llenamos el listado de alumnos con la informacin que se obtuvo del proceso anterior
        alumnosParcialesAdapter = new AlumnosParcialesAdapter(this, gcs, unidad);
        lvAlumnos.setAdapter(alumnosParcialesAdapter);

    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this, getString(R.string.error_parser), Toast.LENGTH_SHORT).show();
        finish(); //finaliza el intent actual para desplegar el anterior
    }
}

From source file:android.support.v7ox.widget.AppCompatSpinner.java

/**
 * Constructs a new spinner with the given context's theme, the supplied
 * attribute set, default styles, popup mode (one of {@link #MODE_DIALOG}
 * or {@link #MODE_DROPDOWN}), and the context against which the popup
 * should be inflated./*from  w  w w. ja va 2s  .  co m*/
 *
 * @param context      The context against which the view is inflated, which
 *                     provides access to the current theme, resources, etc.
 * @param attrs        The attributes of the XML tag that is inflating the view.
 * @param defStyleAttr An attribute in the current theme that contains a
 *                     reference to a style resource that supplies default
 *                     values for the view. Can be 0 to not look for
 *                     defaults.
 * @param mode         Constant describing how the user will select choices from
 *                     the spinner.
 * @param popupTheme   The theme against which the dialog or dropdown popup
 *                     should be inflated. May be {@code null} to use the
 *                     view theme. If set, this will override any value
 *                     specified by
 *                     {@link R.styleable#Spinner_popupTheme}.
 * @see #MODE_DIALOG
 * @see #MODE_DROPDOWN
 */
public AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode,
        Resources.Theme popupTheme) {
    super(context, attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.Spinner, defStyleAttr,
            0);

    mDrawableManager = AppCompatDrawableManager.get();
    mBackgroundTintHelper = new AppCompatBackgroundHelper(this, mDrawableManager);

    if (popupTheme != null) {
        mPopupContext = new ContextThemeWrapper(context, popupTheme);
    } else {
        final int popupThemeResId = a.getResourceId(R.styleable.Spinner_popupTheme, 0);
        if (popupThemeResId != 0) {
            mPopupContext = new ContextThemeWrapper(context, popupThemeResId);
        } else {
            // If we're running on a < M device, we'll use the current context and still handle
            // any dropdown popup
            mPopupContext = !IS_AT_LEAST_M ? context : null;
        }
    }

    if (mPopupContext != null) {
        if (mode == MODE_THEME) {
            if (Build.VERSION.SDK_INT >= 11) {
                // If we're running on API v11+ we will try and read android:spinnerMode
                TypedArray aa = null;
                try {
                    aa = context.obtainStyledAttributes(attrs, ATTRS_ANDROID_SPINNERMODE, defStyleAttr, 0);
                    if (aa.hasValue(0)) {
                        mode = aa.getInt(0, MODE_DIALOG);
                    }
                } catch (Exception e) {
                    Log.i(TAG, "Could not read android:spinnerMode", e);
                } finally {
                    if (aa != null) {
                        aa.recycle();
                    }
                }
            } else {
                // Else, we use a default mode of dropdown
                mode = MODE_DROPDOWN;
            }
        }

        if (mode == MODE_DROPDOWN) {
            final DropdownPopup popup = new DropdownPopup(mPopupContext, attrs, defStyleAttr);
            final TintTypedArray pa = TintTypedArray.obtainStyledAttributes(mPopupContext, attrs,
                    R.styleable.Spinner, defStyleAttr, 0);
            mDropDownWidth = pa.getLayoutDimension(R.styleable.Spinner_android_dropDownWidth,
                    LayoutParams.WRAP_CONTENT);

            popup.setPromptText(a.getString(R.styleable.Spinner_android_prompt));
            pa.recycle();

            mPopup = popup;
            mForwardingListener = new ListPopupWindow.ForwardingListener(this) {
                @Override
                public ListPopupWindow getPopup() {
                    return popup;
                }

                @Override
                public boolean onForwardingStarted() {
                    if (!mPopup.isShowing()) {
                        mPopup.show();
                    }
                    return true;
                }
            };
        }
    }

    final CharSequence[] entries = a.getTextArray(R.styleable.Spinner_android_entries);
    if (entries != null) {
        final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(context,
                R.layout.support_simple_spinner_dropdown_item, entries);
        adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
        setAdapter(adapter);
    }

    a.recycle();

    mPopupSet = true;

    // Base constructors can call setAdapter before we initialize mPopup.
    // Finish setting things up if this happened.
    if (mTempAdapter != null) {
        setAdapter(mTempAdapter);
        mTempAdapter = null;
    }

    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}

From source file:android.support.v7.widget.AppCompatSpinner.java

/**
 * Constructs a new spinner with the given context's theme, the supplied
 * attribute set, default styles, popup mode (one of {@link #MODE_DIALOG}
 * or {@link #MODE_DROPDOWN}), and the context against which the popup
 * should be inflated./*from  w  ww.j  av  a2 s  .co  m*/
 *
 * @param context      The context against which the view is inflated, which
 *                     provides access to the current theme, resources, etc.
 * @param attrs        The attributes of the XML tag that is inflating the view.
 * @param defStyleAttr An attribute in the current theme that contains a
 *                     reference to a style resource that supplies default
 *                     values for the view. Can be 0 to not look for
 *                     defaults.
 * @param mode         Constant describing how the user will select choices from
 *                     the spinner.
 * @param popupTheme   The theme against which the dialog or dropdown popup
 *                     should be inflated. May be {@code null} to use the
 *                     view theme. If set, this will override any value
 *                     specified by
 *                     {@link R.styleable#Spinner_popupTheme}.
 * @see #MODE_DIALOG
 * @see #MODE_DROPDOWN
 */
public AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode,
        Resources.Theme popupTheme) {
    super(context, attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.Spinner, defStyleAttr,
            0);

    mDrawableManager = AppCompatDrawableManager.get();
    mBackgroundTintHelper = new AppCompatBackgroundHelper(this, mDrawableManager);

    if (popupTheme != null) {
        mPopupContext = new ContextThemeWrapper(context, popupTheme);
    } else {
        final int popupThemeResId = a.getResourceId(R.styleable.Spinner_popupTheme, 0);
        if (popupThemeResId != 0) {
            mPopupContext = new ContextThemeWrapper(context, popupThemeResId);
        } else {
            // If we're running on a < M device, we'll use the current context and still handle
            // any dropdown popup
            mPopupContext = !IS_AT_LEAST_M ? context : null;
        }
    }

    if (mPopupContext != null) {
        if (mode == MODE_THEME) {
            if (Build.VERSION.SDK_INT >= 11) {
                // If we're running on API v11+ we will try and read android:spinnerMode
                TypedArray aa = null;
                try {
                    aa = context.obtainStyledAttributes(attrs, ATTRS_ANDROID_SPINNERMODE, defStyleAttr, 0);
                    if (aa.hasValue(0)) {
                        mode = aa.getInt(0, MODE_DIALOG);
                    }
                } catch (Exception e) {
                    Log.i(TAG, "Could not read android:spinnerMode", e);
                } finally {
                    if (aa != null) {
                        aa.recycle();
                    }
                }
            } else {
                // Else, we use a default mode of dropdown
                mode = MODE_DROPDOWN;
            }
        }

        if (mode == MODE_DROPDOWN) {
            final DropdownPopup popup = new DropdownPopup(mPopupContext, attrs, defStyleAttr);
            final TintTypedArray pa = TintTypedArray.obtainStyledAttributes(mPopupContext, attrs,
                    R.styleable.Spinner, defStyleAttr, 0);
            mDropDownWidth = pa.getLayoutDimension(R.styleable.Spinner_android_dropDownWidth,
                    LayoutParams.WRAP_CONTENT);
            popup.setBackgroundDrawable(pa.getDrawable(R.styleable.Spinner_android_popupBackground));
            popup.setPromptText(a.getString(R.styleable.Spinner_android_prompt));
            pa.recycle();

            mPopup = popup;
            mForwardingListener = new ForwardingListener(this) {
                @Override
                public ShowableListMenu getPopup() {
                    return popup;
                }

                @Override
                public boolean onForwardingStarted() {
                    if (!mPopup.isShowing()) {
                        mPopup.show();
                    }
                    return true;
                }
            };
        }
    }

    final CharSequence[] entries = a.getTextArray(R.styleable.Spinner_android_entries);
    if (entries != null) {
        final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(context,
                android.R.layout.simple_spinner_item, entries);
        adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
        setAdapter(adapter);
    }

    a.recycle();

    mPopupSet = true;

    // Base constructors can call setAdapter before we initialize mPopup.
    // Finish setting things up if this happened.
    if (mTempAdapter != null) {
        setAdapter(mTempAdapter);
        mTempAdapter = null;
    }

    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}