List of usage examples for android.widget Spinner setSelection
@Override public void setSelection(int position)
From source file:me.johnmh.boogdroid.ui.BugStatusFragment.java
@NonNull private Spinner setupSpinnerResolution(View view) { Spinner spinnerResolution = (Spinner) view.findViewById(R.id.resolution); BugResolutionChanges resolutionValues = bug.getProduct().getServer().getResolutionValues(); ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity().getBaseContext(), android.R.layout.simple_spinner_item, resolutionValues); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerResolution.setAdapter(adapter); spinnerResolution.setSelection(adapter.getPosition(bug.getResolution())); return spinnerResolution; }
From source file:uk.org.freeflight.wifefinder.MainActivity.java
void setSpinnerItemById(Spinner spinner, long _id) { int spinnerCount = spinner.getCount(); for (int i = 0; i < spinnerCount; i++) { Cursor value = (Cursor) spinner.getItemAtPosition(i); long id = value.getLong(value.getColumnIndex("_id")); if (id == _id) { spinner.setSelection(i); }/* www. j a v a 2s .c om*/ } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java
final static private void setSpinnerHour(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner, CustomSpinnerAdapter adapter, String selected) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_hour)); spinner.setAdapter(adapter);//from w ww. j av a 2s . c o m adapter.clear(); for (int i = 0; i <= 23; i++) if (i > 9) adapter.add("" + i); else adapter.add("0" + i); String hh = selected.substring(0, selected.indexOf(":")); if (!hh.equals("**")) { int hour = Integer.parseInt(hh); spinner.setSelection(hour); } else spinner.setSelection(0); }
From source file:eu.power_switch.gui.dialog.DeveloperOptionsDialog.java
@NonNull @Override/*from w w w . j av a 2s . co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); rootView = inflater.inflate(R.layout.dialog_developer_options, null); geofenceApiHandler = new GeofenceApiHandler(getActivity()); CheckBox checkBox_playStoreMode = (CheckBox) rootView.findViewById(R.id.checkBox_playStoreMode); checkBox_playStoreMode.setChecked(DeveloperPreferencesHandler.getPlayStoreMode()); checkBox_playStoreMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { DeveloperPreferencesHandler.setPlayStoreMode(isChecked); } }); Button resetShowcasesButton = (Button) rootView.findViewById(R.id.button_resetShowcases); resetShowcasesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MaterialShowcaseView.resetAll(getContext()); } }); Button removeAllGeofences = (Button) rootView.findViewById(R.id.button_removeAllGeofences); removeAllGeofences.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { geofenceApiHandler.removeAllGeofences(); } }); Button forceUnknownExceptionDialog = (Button) rootView .findViewById(R.id.button_forceUnknownExceptionDialog); forceUnknownExceptionDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { StatusMessageHandler.showErrorDialog(getContext(), new Exception("Unknown error during runtime!")); } }); Button forceUnhandledException = (Button) rootView.findViewById(R.id.button_forceUnhandledException); forceUnhandledException.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { throw new RuntimeException("Unhandled Exception"); } }); final Spinner spinnerLanguage = (Spinner) rootView.findViewById(R.id.spinner_language); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.locales, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerLanguage.setAdapter(adapter); spinnerLanguage.setSelection(getIndex(spinnerLanguage, DeveloperPreferencesHandler.getLocale().toString())); spinnerLanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String localeString = spinnerLanguage.getItemAtPosition(position).toString(); DeveloperPreferencesHandler.setLocale(new Locale(localeString)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); CheckBox checkBoxForceLanguage = (CheckBox) rootView.findViewById(R.id.checkBox_forceLanguage); checkBoxForceLanguage.setChecked(DeveloperPreferencesHandler.getForceLanguage()); checkBoxForceLanguage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { DeveloperPreferencesHandler.setForceLanguage(isChecked); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(rootView); builder.setTitle("Developer Options"); builder.setNeutralButton(android.R.string.ok, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); // prevent close dialog on touch outside window dialog.show(); return dialog; }
From source file:co.edu.uniajc.vtf.content.SettingsFragment.java
@Override public void setCityValue(int pValue) { Spinner loSpinner = (Spinner) this.getView().findViewById(R.id.spnCities); this.coCityAdapter.notifyDataSetChanged(); int liPosition = getAdapterPositionById(this.coCityAdapter, pValue); loSpinner.setSelection(liPosition); }
From source file:eu.geopaparazzi.library.core.dialogs.ZoomlevelDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View labelDialogView = getActivity().getLayoutInflater().inflate(R.layout.fragment_dialog_zoomlevel, null); builder.setView(labelDialogView);/*from ww w. j a v a 2 s.c o m*/ String minStr = mMinMaxZoomlevels[0] + ""; String maxStr = mMinMaxZoomlevels[1] + ""; int minIndex = 0; int maxIndex = 0; for (int i = 0; i < allZoomlevels.length; i++) { if (allZoomlevels[i].equals(minStr)) { minIndex = i; } if (allZoomlevels[i].equals(maxStr)) { maxIndex = i; } } final Spinner minSpinner = (Spinner) labelDialogView.findViewById(R.id.minZoomLevelSpinner); ArrayAdapter<String> zoomlevelSpinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, allZoomlevels); zoomlevelSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); minSpinner.setAdapter(zoomlevelSpinnerAdapter); minSpinner.setSelection(minIndex); minSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selectedItem = minSpinner.getSelectedItem(); String fieldStr = selectedItem.toString(); mMinMaxZoomlevels[0] = Integer.parseInt(fieldStr); } public void onNothingSelected(AdapterView<?> arg0) { // ignore } }); final Spinner maxSpinner = (Spinner) labelDialogView.findViewById(R.id.maxZoomLevelSpinner); zoomlevelSpinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, allZoomlevels); zoomlevelSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); maxSpinner.setAdapter(zoomlevelSpinnerAdapter); maxSpinner.setSelection(maxIndex); maxSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selectedItem = maxSpinner.getSelectedItem(); String fieldStr = selectedItem.toString(); mMinMaxZoomlevels[1] = Integer.parseInt(fieldStr); } public void onNothingSelected(AdapterView<?> arg0) { // ignore } }); builder.setPositiveButton(R.string.set_properties, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (zoomlevelPropertiesChangeListener != null) { zoomlevelPropertiesChangeListener.onPropertiesChanged(mMinMaxZoomlevels[0], mMinMaxZoomlevels[1]); } } }); builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); // return dialog }
From source file:co.edu.uniajc.vtf.content.SettingsFragment.java
@Override public void setLanguageValue(int pValue) { Spinner loSpinner = (Spinner) this.getView().findViewById(R.id.spnLanguage); this.coLanguageAdapter.notifyDataSetChanged(); int liPosition = getAdapterPositionById(this.coLanguageAdapter, pValue); loSpinner.setSelection(liPosition); }
From source file:eu.geopaparazzi.library.core.dialogs.LabelDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View labelDialogView = getActivity().getLayoutInflater().inflate(R.layout.fragment_dialog_label, null); builder.setView(labelDialogView);/*ww w .java 2 s . c o m*/ CheckBox visibilityCheckBox = (CheckBox) labelDialogView.findViewById(R.id.checkVisibility); visibilityCheckBox.setChecked(mCurrentLabelObject.hasLabel); visibilityCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mCurrentLabelObject.hasLabel = isChecked; } }); mSizeTextView = (TextView) labelDialogView.findViewById(R.id.sizeTextView); mSizeTextView.setText(String.valueOf(mCurrentLabelObject.labelSize)); SeekBar mSizeSeekBar = (SeekBar) labelDialogView.findViewById(R.id.sizeSeekBar); mSizeSeekBar.setOnSeekBarChangeListener(sizeChanged); mSizeSeekBar.setProgress(mCurrentLabelObject.labelSize); List<String> labelFieldsList = mCurrentLabelObject.labelFieldsList; int index = 0; for (int i = 0; i < labelFieldsList.size(); i++) { if (labelFieldsList.get(i).equals(mCurrentLabelObject.label)) { index = i; break; } } final Spinner fieldsSpinner = (Spinner) labelDialogView.findViewById(R.id.labelFieldSpinner); ArrayAdapter<String> fieldsSpinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, labelFieldsList); fieldsSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fieldsSpinner.setAdapter(fieldsSpinnerAdapter); fieldsSpinner.setSelection(index); fieldsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Object selectedItem = fieldsSpinner.getSelectedItem(); String fieldStr = selectedItem.toString(); mCurrentLabelObject.label = fieldStr; } public void onNothingSelected(AdapterView<?> arg0) { // ignore } }); builder.setPositiveButton(R.string.set_properties, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (labelPropertiesChangeListener != null) { labelPropertiesChangeListener.onPropertiesChanged(mCurrentLabelObject); } } }); builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); // return dialog }
From source file:com.simplechatclient.android.LoginFragment.java
public void myStart() { Config current_config = new Config(context); List<DatabaseProfile> profiles = current_config.getProfiles(); profiles_list = new ArrayList<String>(); for (DatabaseProfile profile : profiles) { profiles_list.add(profile.getNick()); }/*from ww w.ja v a2s . co m*/ Button login = (Button) view.findViewById(R.id.button_login); Spinner spinner = (Spinner) view.findViewById(R.id.spinnerNick); ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, profiles_list); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); String nick = Settings.getInstance().get("nick"); int default_position = profiles_list.indexOf(nick); if (default_position != -1) spinner.setSelection(default_position); spinner.setOnItemSelectedListener(spinnerListener); login.setOnClickListener(this); }
From source file:com.armtimes.dialogs.DialogSettings.java
private void initImageQualityControllers(final View view) { Spinner spinner = (Spinner) view.findViewById(R.id.spinnerImageQuality); ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.image_quality_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);//from ww w.j ava2s . co m spinner.setSelection(getImageQuality(getActivity())); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setImageQuality(getActivity(), position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }