List of usage examples for android.widget Spinner setSelection
@Override public void setSelection(int position)
From source file:org.gnucash.android.ui.transaction.dialog.SplitEditorDialogFragment.java
/** * Updates the spinner to the selected transfer account * @param accountId Database ID of the transfer account *///from www .java 2 s . c o m private void setSelectedTransferAccount(long accountId, final Spinner accountsSpinner) { for (int pos = 0; pos < mCursorAdapter.getCount(); pos++) { if (mCursorAdapter.getItemId(pos) == accountId) { accountsSpinner.setSelection(pos); break; } } }
From source file:org.appd.login.V_Role.java
/** * Load Spinner//ww w .j a va 2 s .com * @author Yamel Senih 04/02/2013, 19:51:40 * @param sp * @param id_ctx * @return * @return int */ private int setIDSpinner(Spinner sp, int id_ctx) { for (int i = 0; i < sp.getCount(); i++) { DisplaySpinner ds = (DisplaySpinner) sp.getItemAtPosition(i); if (ds.getID() == id_ctx) { sp.setSelection(i); return id_ctx; } } return 0; }
From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java
private void setupSpinner(int spId, int arrayId, String cur, AdapterView.OnItemSelectedListener listener) { Spinner sp = (Spinner) findViewById(spId); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(cx, arrayId, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sp.setAdapter(adapter);//from w w w . j a v a 2 s . c o m int pos = adapter.getPosition(cur); sp.setSelection(pos); sp.setOnItemSelectedListener(listener); }
From source file:com.gsma.rcs.provisioning.local.ProfileProvisioning.java
@Override public void displayRcsSettings() { if (sLogger.isActivated()) { sLogger.debug("displayRcsSettings"); }/*from www .jav a2 s. c o m*/ Spinner spinner = (Spinner) mRootView.findViewById(R.id.ImsAuthenticationProcedureForMobile); ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, MOBILE_IMS_AUTHENT); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(sRcsSettings.getImsAuthenticationProcedureForMobile().toInt()); mHelper.setContactIdEditText(R.id.ImsUsername, RcsSettingsData.USERPROFILE_IMS_USERNAME); mHelper.setStringEditText(R.id.ImsDisplayName, RcsSettingsData.USERPROFILE_IMS_DISPLAY_NAME); mHelper.setStringEditText(R.id.ImsHomeDomain, RcsSettingsData.USERPROFILE_IMS_HOME_DOMAIN); mHelper.setStringEditText(R.id.ImsPrivateId, RcsSettingsData.USERPROFILE_IMS_PRIVATE_ID); mHelper.setStringEditText(R.id.ImsPassword, RcsSettingsData.USERPROFILE_IMS_PASSWORD); mHelper.setStringEditText(R.id.ImsRealm, RcsSettingsData.USERPROFILE_IMS_REALM); mHelper.setStringEditText(R.id.ImsOutboundProxyAddrForMobile, RcsSettingsData.IMS_PROXY_ADDR_MOBILE); mHelper.setIntEditText(R.id.ImsOutboundProxyPortForMobile, RcsSettingsData.IMS_PROXY_PORT_MOBILE); mHelper.setStringEditText(R.id.ImsOutboundProxyAddrForWifi, RcsSettingsData.IMS_PROXY_ADDR_WIFI); mHelper.setIntEditText(R.id.ImsOutboundProxyPortForWifi, RcsSettingsData.IMS_PROXY_PORT_WIFI); mHelper.setUriEditText(R.id.XdmServerAddr, RcsSettingsData.XDM_SERVER); mHelper.setStringEditText(R.id.XdmServerLogin, RcsSettingsData.XDM_LOGIN); mHelper.setStringEditText(R.id.XdmServerPassword, RcsSettingsData.XDM_PASSWORD); mHelper.setUriEditText(R.id.FtHttpServerAddr, RcsSettingsData.FT_HTTP_SERVER); mHelper.setStringEditText(R.id.FtHttpServerLogin, RcsSettingsData.FT_HTTP_LOGIN); mHelper.setStringEditText(R.id.FtHttpServerPassword, RcsSettingsData.FT_HTTP_PASSWORD); mHelper.setUriEditText(R.id.ImConferenceUri, RcsSettingsData.IM_CONF_URI); mHelper.setUriEditText(R.id.EndUserConfReqUri, RcsSettingsData.ENDUSER_CONFIRMATION_URI); mHelper.setStringEditText(R.id.RcsApn, RcsSettingsData.RCS_APN); TextView txt = (TextView) mRootView.findViewById(R.id.release); txt.setText(sRcsSettings.getGsmaRelease().name()); txt = (TextView) mRootView.findViewById(R.id.user_msg_title); String title = sRcsSettings.getProvisioningUserMessageTitle(); if (title != null) { txt.setText(title); } txt = (TextView) mRootView.findViewById(R.id.user_msg_content); String content = sRcsSettings.getProvisioningUserMessageContent(); if (content != null) { txt.setText(content); } }
From source file:fm.smart.r1.activity.CreateItemActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_item); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); list_id = (String) extras.get("list_id"); cue = (String) extras.get("cue"); response = (String) extras.get("response"); cue_language = (String) extras.get("cue_language"); response_language = (String) extras.get("response_language"); character_cue = (String) extras.get("character_cue"); character_response = (String) extras.get("character_response"); pos = (String) extras.get("pos"); Button button = (Button) findViewById(R.id.create_item_submit); button.setOnClickListener(this); TextView cue_text = (TextView) findViewById(R.id.cue); if (!TextUtils.isEmpty(cue)) { cue_text.setText(cue);/*from w w w . j a v a 2s . c om*/ } TextView response_text = (TextView) findViewById(R.id.response); if (!TextUtils.isEmpty(response)) { response_text.setText(response); } TextView cue_character_text = (TextView) findViewById(R.id.cue_character); if (!TextUtils.isEmpty(character_cue)) { cue_character_text.setText(character_cue); } TextView response_character_text = (TextView) findViewById(R.id.response_character); if (!TextUtils.isEmpty(character_response)) { response_character_text.setText(character_response); } TextView cue_legend = (TextView) findViewById(R.id.create_item_cue_legend); cue_legend.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Term"); TextView response_legend = (TextView) findViewById(R.id.create_item_response_legend); response_legend.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Term"); TextView cue_character_textView = (TextView) findViewById(R.id.create_item_cue_character); cue_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Character Text"); TextView response_character_textView = (TextView) findViewById(R.id.create_item_response_character); response_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Character Text"); List<String> pos_list = new Vector<String>(Utils.POS_MAP.keySet()); Collections.sort(pos_list); ArrayAdapter<String> pos_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, pos_list); // .simple_spinner_item Spinner pos_textView = (Spinner) findViewById(R.id.pos); pos_textView.setAdapter(pos_adapter); if (!TextUtils.isEmpty(pos)) { pos_textView.setSelection(pos_list.indexOf(pos)); } else { pos_textView.setSelection(pos_list.indexOf("Noun")); } EditText cue_character_input_textView = (EditText) findViewById(R.id.cue_character); if (!Utils.isIdeographicLanguage(Main.search_lang)) { cue_character_textView.setVisibility(View.GONE); cue_character_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(character_cue)) { cue_character_input_textView.setText(character_cue); } EditText response_character_input_textView = (EditText) findViewById(R.id.response_character); if (!Utils.isIdeographicLanguage(Main.result_lang)) { response_character_textView.setVisibility(View.GONE); response_character_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(character_response)) { response_character_input_textView.setText(character_response); } }
From source file:com.gsma.rcs.provisioning.local.ServiceProvisioning.java
int setSpinnerParameter(final Spinner spinner, String settingsKey, boolean isSettingInteger, final String[] selection) { Integer parameter;//ww w . jav a2 s . com if (isSettingInteger) { parameter = sRcsSettings.readInteger(settingsKey); } else { String selected = sRcsSettings.readString(settingsKey); parameter = java.util.Arrays.asList(selection).indexOf(selected); } spinner.setSelection(parameter % selection.length); return parameter; }
From source file:mx.com.adolfogarcia.popularmovies.view.fragment.MovieCollectionFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_fragment_movie_collection, menu); MenuItem item = menu.findItem(R.id.menu_item_sort_order); Spinner spinner = (Spinner) MenuItemCompat.getActionView(item); ArrayAdapter<LabeledItem<FetchMoviePageTaskFactory>> adapter = new ArrayAdapter<>(getActivity(), R.layout.list_item_sort_order, mViewModel.getSortOrderOptions()); spinner.setAdapter(adapter);/*w w w . ja va 2 s. c om*/ spinner.setOnItemSelectedListener(mViewModel); spinner.setSelection(mViewModel.getSelectedSortOrderIndex()); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
@Override @SuppressWarnings("unchecked") public void onPriceClicked(String pair, double price) { try {//from w w w. j a va 2 s . co m ScrollView scrollView = (ScrollView) getView(); if (scrollView != null) { scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom()); String[] currencies = pair.split("/"); EditText tradePrice = (EditText) scrollView.findViewById(R.id.TradePrice); tradePrice.setText(String.valueOf(price)); Spinner tradeCurrency = (Spinner) scrollView.findViewById(R.id.TradeCurrency); Spinner tradePriceCurrency = (Spinner) scrollView.findViewById(R.id.TradePriceCurrency); tradeCurrency.setSelection( ((ArrayAdapter<String>) tradeCurrency.getAdapter()).getPosition(currencies[0])); tradePriceCurrency.setSelection( ((ArrayAdapter<String>) tradePriceCurrency.getAdapter()).getPosition(currencies[1])); } } catch (ClassCastException | NullPointerException e) { e.printStackTrace(); } }
From source file:pl.selvin.android.listsyncsample.ui.EditItemActivity.java
void SetupSpinner(final int sid, final Spinner spinner) { for (int i = 0; i < spinner.getCount(); i++) { Cursor value = (Cursor) spinner.getItemAtPosition(i); int id = value.getInt(value.getColumnIndex(BaseColumns._ID)); if (id == sid) { spinner.setSelection(i); break; }/*from w w w. j a va 2 s. c o m*/ } }
From source file:org.runbuddy.tomahawk.adapters.ViewHolder.java
public void fillHeaderView(ArrayList<CharSequence> spinnerItems, int initialSelection, AdapterView.OnItemSelectedListener listener) { ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(TomahawkApp.getContext(), R.layout.dropdown_header_textview, spinnerItems); adapter.setDropDownViewResource(R.layout.dropdown_header_dropdown_textview); Spinner spinner = (Spinner) findViewById(R.id.spinner1); spinner.setAdapter(adapter);/*from w ww . j a v a 2 s.com*/ spinner.setSelection(initialSelection); spinner.setOnItemSelectedListener(listener); }