List of usage examples for android.widget Spinner setSelection
@Override public void setSelection(int position)
From source file:com.xperia64.timidityae.PlayerFragment.java
@SuppressLint("InflateParams") public void showMidiDialog() { AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); View v = getActivity().getLayoutInflater().inflate(R.layout.midi_options, null); Button speedUp = (Button) v.findViewById(R.id.speedUp); Button slowDown = (Button) v.findViewById(R.id.slowDown); Button keyUp = (Button) v.findViewById(R.id.keyUp); Button keyDown = (Button) v.findViewById(R.id.keyDown); Button vplus = (Button) v.findViewById(R.id.vplus); Button vminus = (Button) v.findViewById(R.id.vminus); Button export = (Button) v.findViewById(R.id.exportButton); Button saveCfg = (Button) v.findViewById(R.id.saveCfg); Button loadCfg = (Button) v.findViewById(R.id.loadCfg); Button savedefCfg = (Button) v.findViewById(R.id.savedefCfg); final Button deldefCfg = (Button) v.findViewById(R.id.deldefCfg); deldefCfg.setEnabled(new File(mActivity.currSongName + ".def.tcf").exists() || new File(mActivity.currSongName + ".def.tzf").exists()); tempo = (TextView) v.findViewById(R.id.tempoText); pitch = (TextView) v.findViewById(R.id.pitchText); voices = (TextView) v.findViewById(R.id.voiceText); tempo.setText(String.format(getResources().getString(R.string.mop_tempo), JNIHandler.ttr, (int) (500000 / (double) JNIHandler.tt * 120 * (double) JNIHandler.ttr / 100 + 0.5))); pitch.setText(String.format(getResources().getString(R.string.mop_pitch), ((JNIHandler.koffset > 0) ? "+" : "") + Integer.toString(JNIHandler.koffset))); voices.setText(//from ww w . j a v a 2s .co m String.format(getResources().getString(R.string.mop_voice), JNIHandler.voice, JNIHandler.maxvoice)); speedUp.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(17, 1); JNIHandler.waitUntilReady(); JNIHandler.tb++; } }); slowDown.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(18, 1); JNIHandler.waitUntilReady(); JNIHandler.tb--; } }); keyUp.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(15, 1); JNIHandler.waitUntilReady(); } }); keyDown.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(16, -1); JNIHandler.waitUntilReady(); } }); vplus.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(19, 5); JNIHandler.waitUntilReady(); } }); vminus.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { JNIHandler.controlTimidity(20, 5); JNIHandler.waitUntilReady(); } }); export.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mActivity.dynExport(); } }); saveCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mActivity.saveCfg(); } }); loadCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mActivity.loadCfg(); } }); savedefCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { String value1; String value2; boolean alreadyExists = (new File(mActivity.currSongName + ".def.tcf").exists() || new File(mActivity.currSongName + ".def.tzf").exists()); boolean aWrite = true; String needRename1 = null; String needRename2 = null; String probablyTheRoot = ""; String probablyTheDirectory = ""; try { if (Globals.compressCfg) new FileOutputStream(mActivity.currSongName + ".def.tzf", true).close(); else new FileOutputStream(mActivity.currSongName + ".def.tcf", true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } final boolean canWrite = aWrite; if (!alreadyExists && canWrite) { new File(mActivity.currSongName + ".def.tcf").delete(); new File(mActivity.currSongName + ".def.tzf").delete(); } if (canWrite && new File(mActivity.currSongName).canWrite()) { value1 = mActivity.currSongName + (Globals.compressCfg ? ".def.tzf" : ".def.tcf"); value2 = mActivity.currSongName + (Globals.compressCfg ? ".def.tcf" : ".def.tzf"); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null) { //TODO // Write the file to getExternalFilesDir, then move it with the Uri // We need to tell JNIHandler that movement is needed. // This is pretty much done now? String[] tmp = Globals.getDocFilePaths(getActivity(), mActivity.currSongName); probablyTheDirectory = tmp[0]; probablyTheRoot = tmp[1]; if (probablyTheDirectory.length() > 1) { needRename1 = (mActivity.currSongName).substring( mActivity.currSongName.indexOf(probablyTheRoot) + probablyTheRoot.length()) + (Globals.compressCfg ? ".def.tzf" : ".def.tcf"); needRename2 = (mActivity.currSongName).substring( mActivity.currSongName.indexOf(probablyTheRoot) + probablyTheRoot.length()) + (Globals.compressCfg ? ".def.tcf" : ".def.tzf"); value1 = probablyTheDirectory + mActivity.currSongName.substring(mActivity.currSongName.lastIndexOf('/')) + (Globals.compressCfg ? ".def.tzf" : ".def.tcf"); value2 = probablyTheDirectory + mActivity.currSongName.substring(mActivity.currSongName.lastIndexOf('/')) + (Globals.compressCfg ? ".def.tcf" : ".def.tzf"); } else { Toast.makeText(getActivity(), "Could not write config file. Did you give Timidity write access to the root of your external sd card?", Toast.LENGTH_SHORT).show(); return; } } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Toast.makeText(getActivity(), "Could not write config file. Did you give Timidity write access to the root of your external sd card?", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), "Could not write config file. Permission denied.", Toast.LENGTH_SHORT).show(); } return; } final String finalval1 = value1; final String finalval2 = value2; final String needToRename1 = needRename1; final String needToRename2 = needRename2; final String probRoot = probablyTheRoot; if (alreadyExists) { AlertDialog dialog = new AlertDialog.Builder(mActivity).create(); dialog.setTitle("Warning"); dialog.setMessage("Overwrite default config file?"); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (needToRename1 != null) { Globals.tryToDeleteFile(getActivity(), probRoot + needToRename1); Globals.tryToDeleteFile(getActivity(), finalval1); Globals.tryToDeleteFile(getActivity(), probRoot + needToRename2); Globals.tryToDeleteFile(getActivity(), finalval2); } else { Globals.tryToDeleteFile(getActivity(), finalval1); Globals.tryToDeleteFile(getActivity(), finalval2); } } else { new File(mActivity.currSongName + ".def.tcf").delete(); new File(mActivity.currSongName + ".def.tzf").delete(); } mActivity.localfinished = false; mActivity.saveCfgPart2(finalval1, needToRename1); deldefCfg.setEnabled(true); /*Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 16); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), mActivity.currSongName+".def.tcf"); getActivity().sendBroadcast(new_intent); deldefCfg.setEnabled(true);*/ } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } else { /*Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 16); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), mActivity.currSongName+".def.tcf"); getActivity().sendBroadcast(new_intent); deldefCfg.setEnabled(true);*/ mActivity.localfinished = false; mActivity.saveCfgPart2(finalval1, needToRename1); deldefCfg.setEnabled(true); } } }); deldefCfg.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (new File(mActivity.currSongName + ".def.tcf").exists() || new File(mActivity.currSongName + ".def.tzf").exists()) { boolean aWrite = true; try { if (Globals.compressCfg) new FileOutputStream(mActivity.currSongName + ".def.tzf", true).close(); else new FileOutputStream(mActivity.currSongName + ".def.tcf", true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } final boolean canWrite = aWrite; AlertDialog dialog = new AlertDialog.Builder(mActivity).create(); dialog.setTitle("Warning"); dialog.setMessage("Really delete default config file?"); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Globals.tryToDeleteFile(getActivity(), mActivity.currSongName + ".def.tzf"); Globals.tryToDeleteFile(getActivity(), mActivity.currSongName + ".def.tcf"); } else { new File(mActivity.currSongName + ".def.tcf").delete(); new File(mActivity.currSongName + ".def.tzf").delete(); } deldefCfg.setEnabled(false); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } } }); final Spinner x = (Spinner) v.findViewById(R.id.resampSpinner); List<String> arrayAdapter = new ArrayList<String>(); for (String yyy : Globals.sampls) arrayAdapter.add(yyy); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, arrayAdapter); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); x.setAdapter(dataAdapter); firstSelection = true; x.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long id) { if (firstSelection) firstSelection = false; else { JNIHandler.setResampleTimidity(JNIHandler.currsamp = pos); JNIHandler.seekTo(JNIHandler.currTime); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); x.setSelection(JNIHandler.currsamp); if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) v.setBackgroundColor(Globals.theme == 1 ? Color.WHITE : Color.BLACK); b.setView(v); b.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); b.setTitle(getActivity().getResources().getString(R.string.mop)); ddd = b.create(); ddd.show(); }
From source file:com.androguide.honamicontrol.kernel.KernelFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.profiles, menu); MenuItem item = menu.findItem(R.id.profile_spinner); View spinner = item != null ? item.getActionView() : null; if (spinner instanceof android.widget.Spinner) { final SharedPreferences profilePrefs = super.getActivity().getSharedPreferences("PROFILES", 0); Spinner profiles = (Spinner) spinner; profiles.setAdapter(ArrayAdapter.createFromResource(super.getActivity(), R.array.profiles_array, R.layout.spinner_action_row)); profiles.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*from w ww.ja va 2 s . co m*/ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { final int currProfile = profilePrefs.getInt("CURR_PROFILE", 5); ActionBarActivity context = (ActionBarActivity) getActivity(); switch (i) { case 0: if (profileCounter > 0 && i != currProfile) ProfileEnabler.enableProfile(new BatteryMaxProfile(), context); profileCounter++; break; case 1: if (profileCounter > 0 && i != currProfile) ProfileEnabler.enableProfile(new BatteryProfile(), context); profileCounter++; break; case 2: if (profileCounter > 0 && i != currProfile) ProfileEnabler.enableProfile(new BalancedProfile(), context); profileCounter++; break; case 3: if (profileCounter > 0 && i != currProfile) ProfileEnabler.enableProfile(new PerformanceProfile(), context); profileCounter++; break; case 4: if (profileCounter > 0 && i != currProfile) ProfileEnabler.enableProfile(new BenchmarkProfile(), context); profileCounter++; break; } profilePrefs.edit().putInt("CURR_PROFILE", i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); profiles.setSelection(profilePrefs.getInt("CURR_PROFILE", 5)); } }
From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java
void updateRefreshSpinner() { Spinner refreshSpinner = findById(settingsContainer, R.id.spinner_lwq_settings_refresh); final AdapterView.OnItemSelectedListener onItemSelectedListener = refreshSpinner .getOnItemSelectedListener(); refreshSpinner.setOnItemSelectedListener(null); final long refreshPreference = LWQPreferences.getRefreshPreference(); final int[] refreshValues = getResources().getIntArray(R.array.refresh_preference_values); for (int i = 0; i < refreshValues.length; i++) { if (refreshPreference == refreshValues[i]) { refreshSpinner.setSelection(i); break; }//from w w w.jav a2 s .c o m } refreshSpinner.setOnItemSelectedListener(onItemSelectedListener); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerCompareResult(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_action_compare_select_type)); spinner.setAdapter(adapter);//from w w w. j av a 2s . co m adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_COMPARE_RESULT_CONTINUE); adapter.add(PROFILE_ACTION_TYPE_COMPARE_RESULT_ABORT); adapter.add(PROFILE_ACTION_TYPE_COMPARE_RESULT_SKIP); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) { spinner.setSelection(i); break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerMessageType(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_action_compare_select_type)); spinner.setAdapter(adapter);/*from w w w.j ava2 s . c om*/ adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_MESSAGE_DIALOG); adapter.add(PROFILE_ACTION_TYPE_MESSAGE_NOTIFICATION); // adapter.add(PROFILE_ACTION_TYPE_MESSAGE_WITHOUT_TEXT); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) { spinner.setSelection(i); break; } }
From source file:org.runbuddy.tomahawk.ui.fragments.ChartsSelectorFragment.java
private void populateCountryCodeSpinner(final ScriptChartsProvider provider, final boolean isInitial) { if (mCountryCodePicker != null && provider != null) { provider.getCountryCodes().done(new DoneCallback<ScriptChartsCountryCodes>() { @Override//from w w w. jav a 2s .c o m public void onDone(final ScriptChartsCountryCodes result) { final ArrayList<String> countryCodes = new ArrayList<>(); final ArrayList<String> displayedCountryCodes = new ArrayList<>(); final ArrayList<String> displayedCountryCodeNames = new ArrayList<>(); for (Pair<String, String> countryCode : result.codes) { countryCodes.add(countryCode.second); displayedCountryCodes.add(countryCode.second.toUpperCase()); displayedCountryCodeNames.add(countryCode.first); } int initialPosition = -1; if (isInitial) { // Must be the first call of this method. So we should set the initially // stored (or default) selection of the spinner String storedCountryCode = ChartsSelectorFragment.this.getStoredCountryCode(provider); if (storedCountryCode == null) { storedCountryCode = result.defaultCode; } for (int i = 0; i < countryCodes.size(); i++) { if (countryCodes.get(i).equalsIgnoreCase(storedCountryCode)) { initialPosition = i; } } } Spinner mCountryCodePickerSpinner = (Spinner) mCountryCodePicker.getActionView(); CountryCodeSpinnerAdapter adapter = new CountryCodeSpinnerAdapter(TomahawkApp.getContext(), R.layout.spinner_textview_country_code, displayedCountryCodes, displayedCountryCodeNames); adapter.setDropDownViewResource(R.layout.spinner_dropdown_textview_country_code); mCountryCodePickerSpinner.setAdapter(adapter); mCountryCodePickerSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedCountryCode = countryCodes.get(position); String storedCountryCode = ChartsSelectorFragment.this.getStoredCountryCode(provider); if (storedCountryCode == null) { storedCountryCode = result.defaultCode; } if (!storedCountryCode.equals(selectedCountryCode)) { storeCountryCode(provider, selectedCountryCode); mSelectedFragmentInfo.mBundle.putString( ChartsPagerFragment.CHARTSPROVIDER_COUNTRYCODE, selectedCountryCode); // Refresh the currently shown ChartsPagerFragment FragmentUtils.replace((TomahawkMainActivity) getActivity(), mSelectedFragmentInfo.mClass, mSelectedFragmentInfo.mBundle, R.id.content_frame); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); if (initialPosition >= 0) { mCountryCodePickerSpinner.setSelection(initialPosition); } } }); } }
From source file:net.phase.wallet.Currency.java
protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DIALOG_URL: TextView tv = (TextView) dialog.findViewById(R.id.pasteBinHelpText); tv.setMovementMethod(LinkMovementMethod.getInstance()); break;/* ww w.j a v a 2 s . c o m*/ case DIALOG_FILE: TextView tvhelp = (TextView) dialog.findViewById(R.id.helpText); tvhelp.setMovementMethod(LinkMovementMethod.getInstance()); Spinner fileSpinner = (Spinner) dialog.findViewById(R.id.fileInput); File[] files = Environment.getExternalStorageDirectory().listFiles(fileFilter); if (files == null || files.length == 0) { toastMessage("No files found on sdcard"); } else { ArrayAdapter<File> adapter = new ArrayAdapter<File>(this, android.R.layout.simple_spinner_item, files); fileSpinner.setAdapter(adapter); } break; case DIALOG_PASTE: EditText keyText = (EditText) dialog.findViewById(R.id.keysText); keyText.setText(""); break; case DIALOG_OPTIONS: EditText reqText = (EditText) dialog.findViewById(R.id.reqText); reqText.setText(Integer.toString(maxlength)); Spinner currencySpinner = (Spinner) dialog.findViewById(R.id.currencySpinner); Spinner decimalSpinner = (Spinner) dialog.findViewById(R.id.decpointSpinner); String current = getActiveCurrency(); String[] currencies = { current }; try { currencies = Currency.getAvailableCurrencies(); } catch (IOException e) { WalletActivity.toastMessage("Warning: unable to obtain currency information"); } catch (JSONException e) { } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, currencies); currencySpinner.setAdapter(adapter); for (int i = 0; i < currencies.length; i++) { if (currencies[i].equals(current)) { currencySpinner.setSelection(i); break; } } Integer[] decimaloptions = { 0, 1, 2, 3, 4, 5 }; ArrayAdapter<Integer> adapter2 = new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item, decimaloptions); decimalSpinner.setAdapter(adapter2); for (int i = 0; i < decimaloptions.length; i++) { if (decimaloptions[i].intValue() == decimalpoints) { decimalSpinner.setSelection(i); break; } } break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerCompareTarget(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_action_compare_select_target)); spinner.setAdapter(adapter);/*from ww w .j av a2 s . com*/ adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_BATTERY); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_BLUETOOTH); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_LIGHT); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_WIFI); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_TIME); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) { spinner.setSelection(i); break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerActivityDataType(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner, CustomSpinnerAdapter adapter, String selected) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setPrompt(//from w ww.java 2 s .c o m mGlblParms.context.getString(R.string.msgs_edit_profile_action_select_activity_data_type)); spinner.setAdapter(adapter); adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_NONE); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_EXTRA); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_URI); int sel_no = 0; if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_EXTRA)) sel_no = 1; else if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_URI)) sel_no = 2; spinner.setSelection(sel_no); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerExtraDataType(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner, CustomSpinnerAdapter adapter, String selected) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setPrompt(/*from w w w . j a va 2 s .com*/ mGlblParms.context.getString(R.string.msgs_edit_profile_action_select_activity_data_type)); spinner.setAdapter(adapter); adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN); int sel_no = 0; if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) sel_no = 0; else if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) sel_no = 1; else sel_no = 2; spinner.setSelection(sel_no); }