List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:Main.java
public static void fillSpinner(Context context, Spinner lv, List<String> ls) { SpinnerAdapter adapter = new ArrayAdapter(context, android.R.layout.simple_spinner_item, ls); lv.setAdapter(adapter); }
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); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); }
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 source file:Main.java
/** * Carica i dati di uno spinner con la lista passata * @param context - Context/* www .ja v a 2 s. c o 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:com.hybris.mobile.app.commerce.helper.ProductHelper.java
/** * Fill Spinner list with arraylist of variantMatrixElement * * @param context//from w w w . ja v a 2 s . c o m * @param spinner * @param variants * @param position */ public static void populateSpinner(Context context, Spinner spinner, List<VariantOption> variants, int position) { if (spinner != null && variants != null && !variants.isEmpty()) { VariantAdapter mVariantAdapter = new VariantAdapter(context, R.layout.item_product_variant, variants); spinner.setAdapter(mVariantAdapter); spinner.setPrompt(context.getString(R.string.choose_variant, ((List<VariantOptionQualifier>) variants.get(0).getVariantOptionQualifiers()).get(0) .getName())); spinner.setVisibility(View.VISIBLE); spinner.setSelection(position < variants.size() ? position : 0); } }
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);//from w ww.j a v a 2s . com 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(); }
From source file:org.hedgewars.hedgeroid.MapFragment.java
private static Spinner prepareSpinner(View v, int id, List<String> items, OnItemSelectedListener itemSelectedListener) { Spinner spinner = (Spinner) v.findViewById(id); ArrayAdapter<String> adapter = new ArrayAdapter<String>(v.getContext(), R.layout.listview_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(itemSelectedListener); return spinner; }
From source file:com.nextgis.mobile.map.LocalTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, int type, final Uri uri, final LocalTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);//from w ww .jav a 2s .c o m 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_qtiles)); 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(1); } else { spinner.setSelection(2); } final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); 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(), tmsType, uri); } 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(); }
From source file:com.appnexus.opensdkapp.SettingsFragment.java
private static Spinner initDropdown(View out, ViewGroup container, int resId, int stringsId) { Spinner dropdown = (Spinner) out.findViewById(resId); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(container.getContext(), stringsId, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); dropdown.setAdapter(adapter); return dropdown; }
From source file:com.fuzz.android.limelight.model.ChapterTransition.java
public static void getDrawerPosition() { LayoutInflater inflater = LimeLight.getActivity().getLayoutInflater(); View drawerView = inflater.inflate(R.layout.choose_drawer_item, null); AlertDialog.Builder builder = new AlertDialog.Builder(LimeLight.getActivity()); builder.setTitle(R.string.choose_drawer_item); builder.setView(drawerView);//from www .j a va2 s . com final Spinner positionSpinner = (Spinner) drawerView.findViewById(R.id.positionSpinner); ArrayList<String> items = new ArrayList<String>(); for (int i = 0; i < LimeLight.getDrawerList().getAdapter().getCount(); i++) { items.add(i + ""); } ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(LimeLight.getActivity(), android.R.layout.simple_spinner_dropdown_item, items); positionSpinner.setAdapter(spinnerArrayAdapter); positionSpinner.setSelection(mDrawerItemPosition); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mDrawerItemPosition = Integer.valueOf(positionSpinner.getSelectedItem().toString()); } }); builder.setNegativeButton(R.string.cancel, null); builder.create(); builder.show(); }