List of usage examples for android.widget ArrayAdapter setDropDownViewResource
public void setDropDownViewResource(@LayoutRes int resource)
Sets the layout resource to create the drop down views.
From source file:Main.java
public static void fillSpinner(Context ctx, Spinner spinner, String[] data) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx, android.R.layout.simple_spinner_item, data); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/*from ww w . j a v a 2 s. c o m*/ }
From source file:Main.java
/** * Creates a standard Android spinner adapter. Input items can be of any type. * //from ww w. j ava2s . c o m * @param context Context with which to create the adapter * @param items List of items to populate the adapter with * @return The created adapter */ public static <E> ArrayAdapter<E> createSpinnerAdapter(Context context, List<E> items) { ArrayAdapter<E> adapter = createAdapter(context, android.R.layout.select_dialog_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); return adapter; }
From source file:Main.java
public static ArrayAdapter<String> getSpinnerAdapter(Context context, String[] datas) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, datas);/*from ww w. j a va 2 s .co m*/ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); return adapter; }
From source file:Main.java
/** * Carica i dati di uno spinner con la lista passata * @param context - Context//from w w w . ja v a 2 s.co m * @param spinner - Spinner da caricare * @param data - List di stringhe con cuoi caricare lo spinner * @param selectedPosition - Posizione di selezione (minimo zero) */ public static void setSpinnerData(Context context, Spinner spinner, List<String> data, int selectedPosition) { if (selectedPosition < 0) selectedPosition = 0; ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, data); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(selectedPosition); }
From source file:Main.java
public static void SetSpinnerData(int redID, List<String> list, View view) { Spinner spinner = (Spinner) view.findViewById(redID); ArrayAdapter<String> adapter = new ArrayAdapter<String>(view.getContext(), android.R.layout.simple_spinner_item, list); spinner.setAdapter(adapter);//from w w w. j a va 2 s. c o m adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); }
From source file:com.einzig.ipst2.util.ThemeHelper.java
public static ArrayAdapter<String> styleSpinner(String[] adapterArray, Context context) { ArrayAdapter<String> portalTypeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, adapterArray);/*from ww w . j a v a 2 s .c o m*/ portalTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); return portalTypeAdapter; }
From source file:br.com.bioscada.apps.biotracks.util.AccountUtils.java
/** * Sets up account spinner.//from w w w . j a va 2s.c o m * * @param fragmentActivity tyhe fragment activity * @param spinner the spinner * @param accounts the accounts */ public static void setupAccountSpinner(FragmentActivity fragmentActivity, Spinner spinner, Account[] accounts) { if (accounts.length > 1) { String shareTrackAccount = PreferencesUtils.getString(fragmentActivity, R.string.share_track_account_key, PreferencesUtils.SHARE_TRACK_ACCOUNT_DEFAULT); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(fragmentActivity, R.layout.account_spinner_item); int selection = 0; for (int i = 0; i < accounts.length; i++) { String name = accounts[i].name; adapter.add(name); if (name.equals(shareTrackAccount)) { selection = i; } } adapter.setDropDownViewResource(R.layout.account_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(selection); } }
From source file:nl.mpcjanssen.simpletask.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: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:com.nextgis.mobile.map.RemoteTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, String layerUrl, int type, final RemoteTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);// w w w. j av a 2 s . c om final EditText url = new EditText(map.getContext()); url.setText(layerUrl); final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerUrl = new TextView(map.getContext()); stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(0); } else { spinner.setSelection(1); } linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerUrl); linearLayout.addView(url); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), url.getText().toString(), tmsType); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }