List of usage examples for android.widget Spinner setSelection
@Override public void setSelection(int position)
From source file:at.bitfire.davdroid.mirakel.syncadapter.EnterCredentialsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.enter_credentials, container, false); // protocol selection spinner textHttpWarning = (TextView) v.findViewById(R.id.http_warning); Spinner spnrProtocol = (Spinner) v.findViewById(R.id.select_protocol); spnrProtocol.setOnItemSelectedListener(new OnItemSelectedListener() { @Override//from www . ja v a 2s. co m public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { protocol = parent.getAdapter().getItem(position).toString(); textHttpWarning.setVisibility(protocol.equals("https://") ? View.GONE : View.VISIBLE); } @Override public void onNothingSelected(AdapterView<?> parent) { protocol = null; } }); spnrProtocol.setSelection(1); // HTTPS // other input fields editBaseURL = (EditText) v.findViewById(R.id.baseURL); editBaseURL.addTextChangedListener(this); editUserName = (EditText) v.findViewById(R.id.userName); editUserName.addTextChangedListener(this); editPassword = (EditText) v.findViewById(R.id.password); editPassword.addTextChangedListener(this); checkboxPreemptive = (CheckBox) v.findViewById(R.id.auth_preemptive); // hook into action bar setHasOptionsMenu(true); return v; }
From source file:nl.jalava.appostle.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = getBaseContext();/*from w ww. j ava2 s .com*/ Toolbar mToolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(mToolbar); // Spinner for choosing application type. Spinner spinner_app = (Spinner) findViewById(R.id.app_types); spinner_app.setVisibility(View.VISIBLE); ArrayAdapter<CharSequence> apptype = ArrayAdapter.createFromResource(mToolbar.getContext(), R.array.app_types, android.R.layout.simple_spinner_item); apptype.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner_app.setAdapter(apptype); // Select. int app_type = getSharedPreferences("AppListFragment", Context.MODE_PRIVATE) .getInt(AppListFragment.PREFS_APP_TYPE, 0); spinner_app.setSelection(app_type); spinner_app.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { AppListFragment fragment = (AppListFragment) getFragmentManager() .findFragmentById(R.id.listFragment); if (fragment != null && fragment.isVisible()) { fragment.doUpdate(position); } } @Override public void onNothingSelected(AdapterView<?> arg0) { // Not used. } }); /* mDrawer = (NavigationView) findViewById(R.id.main_drawer); mDrawer.setNavigationItemSelectedListener(this); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); mDrawerLayout.closeDrawer(GravityCompat.START); */ }
From source file:org.ale.scanner.zotero.EditItemActivity.java
private void fillForm() { // Clear any previous data from the form LinearLayout container = ((LinearLayout) findViewById(R.id.editContainer)); container.removeAllViews();// w ww . j a va 2 s .c om // Get the JSON we'll be working from. JSONObject info = mWorkingItem.getSelectedInfo(); final String[] fields; // XXX: temporary hack. In-order list of fields if (ItemType.book.equals(info.optString(ItemField.itemType))) { fields = new String[] { "title", "creators", "abstractNote", "series", "seriesNumber", "volume", "numberOfVolumes", "edition", "place", "publisher", "date", "numPages", "language", "ISBN", "shortTitle", "url", "accessDate", "archive", "archiveLocation", "libraryCatalog", "callNumber", "rights", "extra", "notes", "tags" }; } else { // XXX: Assumes journalArticle fields = new String[] { "title", "creators", "abstractNote", "publicationTitle", "volume", "issue", "pages", "date", "series", "seriesTitle", "seriesText", "journalAbbreviation", "language", "DOI", "ISSN", "shortTitle", "url", "accessDate", "archive", "archiveLocation", "libraryCatalog", "callNumber", "rights", "extra", "tags", "notes" }; } LinearLayout row; LinearLayout crow; int row_ctr = 0; for (String field : fields) { if (field.equals(ItemField.itemType)) continue; if (field.equals(ItemField.creators)) { row = mCreatorList = (LinearLayout) mInflater.inflate(R.layout.edit_creators, container, false); JSONArray creators = info.optJSONArray(field); if (creators == null || creators.length() == 0) { addCreator(); // Empty creator row for new creators } else { for (int c = 0; c < creators.length(); c++) { JSONObject creator = creators.optJSONObject(c); if (creator == null) continue; crow = addCreator(); Spinner sp = (Spinner) crow.findViewById(R.id.creator_type); EditText et = (EditText) crow.findViewById(R.id.creator); String curtype = creator.optString(CreatorType.type); int selection = CreatorType.Book.indexOf(curtype); sp.setSelection(selection >= 0 ? selection : 0); String name = creator.optString(ItemField.Creator.name); if (TextUtils.isEmpty(name)) { String[] firstlast = { creator.optString(ItemField.Creator.firstName), creator.optString(ItemField.Creator.lastName) }; name = TextUtils.join(" ", firstlast); } et.setText(name); } } } else if (field.equals(ItemField.notes)) { row = mNoteList = (LinearLayout) mInflater.inflate(R.layout.edit_notes, container, false); JSONArray notes = info.optJSONArray(field); if (notes == null || notes.length() == 0) { addNote(); // Empty note row for new notes } else { for (int c = 0; c < notes.length(); c++) { JSONObject note = notes.optJSONObject(c); if (note == null) continue; crow = addNote(); EditText et = (EditText) crow.findViewById(R.id.content); et.setText(note.optString(ItemField.Note.note)); } } } else if (field.equals(ItemField.tags)) { row = mTagList = (LinearLayout) mInflater.inflate(R.layout.edit_tags, container, false); JSONArray tags = info.optJSONArray(field); if (tags == null || tags.length() == 0) { addTag(); // Empty tag row for new tags } else { for (int c = 0; c < tags.length(); c++) { JSONObject tag = tags.optJSONObject(c); if (tag == null) continue; crow = addTag(); EditText et = (EditText) crow.findViewById(R.id.content); et.setText(tag.optString(ItemField.Tag.tag)); } } } else { row = (LinearLayout) mInflater.inflate(R.layout.edit_field, container, false); TextView tv_lbl = (TextView) row.findViewById(R.id.label); EditText et = (EditText) row.findViewById(R.id.content); tv_lbl.setText(ItemField.Localized.get(field)); tv_lbl.setTag(field); et.setText(info.optString(field)); } container.addView(row); setRowColor(row, row_ctr); row_ctr++; } }
From source file:ca.frozen.rpicameraviewer.activities.SourceFragment.java
private void setViews(Source source) { // get the view View view = getView();// ww w . j a v a 2s.co m // set the connection type if (forCamera) { Spinner spinner = (Spinner) view.findViewById(R.id.source_connection_type); if (spinner.getVisibility() == View.VISIBLE) { for (int i = 0; i < connectionTypes.size(); i++) { Source.ConnectionType connectionType = connectionTypes.get(i); if (connectionType == source.connectionType) { spinner.setSelection(i); break; } } } } // set the address if (forCamera || source.connectionType == Source.ConnectionType.RawMulticast) { EditText edit = (EditText) view.findViewById(R.id.source_address); edit.setText(source.address); } // set the numeric values setNumber(view, R.id.source_port, source.port); setNumber(view, R.id.source_width, source.width); setNumber(view, R.id.source_height, source.height); setNumber(view, R.id.source_fps, source.fps); setNumber(view, R.id.source_bps, source.bps); }
From source file:com.androzic.waypoint.WaypointProperties.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Androzic application = Androzic.getApplication(); View rootView = inflater.inflate(R.layout.act_waypoint_properties, container, false); tabHost = (TabHost) rootView.findViewById(R.id.tabhost); tabHost.setup();//from ww w .j a v a 2 s.co m tabHost.addTab( tabHost.newTabSpec("main").setIndicator(getString(R.string.primary)).setContent(R.id.properties)); tabHost.addTab(tabHost.newTabSpec("advanced").setIndicator(getString(R.string.advanced)) .setContent(R.id.advanced)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 50; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 50; } name = (TextView) rootView.findViewById(R.id.name_text); description = (TextView) rootView.findViewById(R.id.description_text); altitude = (TextView) rootView.findViewById(R.id.altitude_text); proximity = (TextView) rootView.findViewById(R.id.proximity_text); iconValue = null; ImageButton icon = (ImageButton) rootView.findViewById(R.id.icon_button); icon.setImageDrawable(getResources().getDrawable(R.drawable.ic_highlight_remove_white_24dp)); if (waypoint.drawImage) { Bitmap b = BitmapFactory.decodeFile(application.markerPath + File.separator + waypoint.marker); if (b != null) { icon.setImageBitmap(b); iconValue = waypoint.marker; } } icon.setOnClickListener(iconOnClickListener); ArrayList<String> items = new ArrayList<String>(); for (WaypointSet wptset : application.getWaypointSets()) { items.add(wptset.name); } waypointSet = (Spinner) rootView.findViewById(R.id.set_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); waypointSet.setAdapter(adapter); markercolor = (ColorButton) rootView.findViewById(R.id.markercolor_button); textcolor = (ColorButton) rootView.findViewById(R.id.textcolor_button); coordDeg = (ViewGroup) rootView.findViewById(R.id.coord_deg); coordUtm = (ViewGroup) rootView.findViewById(R.id.coord_utm); coordMgrs = (ViewGroup) rootView.findViewById(R.id.coord_mgrs); coordLatDeg = (ViewGroup) rootView.findViewById(R.id.coord_lat_deg); coordLatMin = (ViewGroup) rootView.findViewById(R.id.coord_lat_min); coordLatSec = (ViewGroup) rootView.findViewById(R.id.coord_lat_sec); coordLonDeg = (ViewGroup) rootView.findViewById(R.id.coord_lon_deg); coordLonMin = (ViewGroup) rootView.findViewById(R.id.coord_lon_min); coordLonSec = (ViewGroup) rootView.findViewById(R.id.coord_lon_sec); Spinner coordformat = (Spinner) rootView.findViewById(R.id.coordformat_spinner); coordformat.setOnItemSelectedListener(this); coordformat.setSelection(StringFormatter.coordinateFormat); return rootView; }
From source file:com.teitsmch.hearthmaker.MainActivity.java
public void selectItem(MenuItem currentItem) { // Reset Spinner positions mClassSpinner.setSelection(0);/* w w w .j a v a2s . co m*/ for (Spinner spinner : spinners) { spinner.setSelection(0); } // Reset Search View if (mFragment != null) { searchView.setQuery("", true); searchView.onActionViewCollapsed(); } // Reset Subtitle updateSubtitle(null); // update the main content by replacing fragments switch (currentItem.getItemId()) { case CATALOG_FRAGMENT_ID: mMainActivityPresenter.resetFilter(); mFragment = CardViewFragment.newInstance(); if (mSpinnerView.getVisibility() == View.VISIBLE) { mSpinnerView.setVisibility(View.GONE); } currentClasses.clear(); currentClasses.add("CLEAR"); currentClasses.addAll(Arrays.asList(dialogClasses)); mClassSpinnerAdapter.notifyDataSetChanged(); break; case R.id.nav_new_deck: createNewDeckDialog(); return; default: if (currentItem.getGroupId() == R.id.navigation_deck_group) { mFragment = DeckFragment.newInstance(currentDeckClass, currentItem.getItemId(), (String) currentItem.getTitle()); currentDeckClass = ""; if (mSpinnerView.getVisibility() == View.VISIBLE) { mSpinnerView.setVisibility(View.GONE); updateSubtitle(cardCount); } } break; } FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.content_frame, mFragment); ft.commit(); // Close the drawer setTitle(currentItem.getTitle()); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
private void setSpinnerCountry(Spinner spinner) { TelephonyManager tel = (TelephonyManager) getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE); String country = tel.getSimCountryIso(); Log.i(tag, "country: " + country); if (Text.isEmpty(country)) { spinner.setSelection(92); // India return;/*w w w .j a v a 2s. co m*/ } CountryMap m = new CountryMap(); Log.i(tag, "index: " + m.getIndex(country.toUpperCase())); spinner.setSelection(m.getIndex(country.toUpperCase())); Log.i(tag, "country: " + m.getCallingCode(country.toUpperCase())); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java
final static private void setSpinnerDateTimeType(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner, AdapterDateTimeTypeSpinner adapter, String selected) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_date_time_type)); spinner.setAdapter(adapter);//from w w w . j a va 2 s. co m adapter.clear(); adapter.add(PROFILE_DATE_TIME_TYPE_ONE_SHOT); adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_YEAR); adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_MONTH); adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_DAY); adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_HOUR); adapter.add(PROFILE_DATE_TIME_TYPE_DAY_OF_THE_WEEK); adapter.add(PROFILE_DATE_TIME_TYPE_INTERVAL); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) spinner.setSelection(i); }
From source file:com.z299studio.pb.ActionDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (Application.getInstance() == null || Application.getInstance().getAccountManager() == null) { return null; }/*from w w w. j av a 2 s.c o m*/ View rootView; int[] layouts = { R.layout.dialog_authenticate, R.layout.dialog_export, R.layout.dialog_import, R.layout.dialog_reset_pwd, R.layout.dialog_credits, R.layout.dialog_license, R.layout.dialog_authenticate }; rootView = inflater.inflate(layouts[mDlgType], container, false); mOkButton = (Button) rootView.findViewById(R.id.ok); if (mOkButton != null) { mOkButton.setOnClickListener(this); } View cancel = rootView.findViewById(R.id.cancel); if (cancel != null) { cancel.setOnClickListener(this); } if (mDlgType != ACTION_EXPORT && mOkButton != null) { mOkButton.setEnabled(false); mOkButton.setAlpha(0.4f); } switch (mDlgType) { case ACTION_EXPORT: case ACTION_IMPORT: Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getActivity(), mDlgType == ACTION_EXPORT ? R.array.file_types : R.array.file_types_import, android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); spinner.setSelection(mFileType); spinner.setOnItemSelectedListener(this); if (mDlgType == ACTION_IMPORT) { int ids[] = { R.id.ignore, R.id.keepall, R.id.overwrite }; for (int i = 0; i < ids.length; ++i) { RadioButton rb = (RadioButton) rootView.findViewById(ids[i]); rb.setOnClickListener(this); if (i == mOption) { rb.setChecked(true); } } mSelectButton = (Button) rootView.findViewById(R.id.select); mSelectButton.setOnClickListener(this); } break; case ACTION_AUTHENTICATE2: ((TextView) rootView.findViewById(R.id.auth_desc)).setText(R.string.diff_pwd); ((Button) rootView.findViewById(R.id.cancel)).setText(R.string.discard); // no break to use the logic of authenticate case ACTION_AUTHENTICATE: mPasswordEdits[1] = (EditText) rootView.findViewById(R.id.et_password); mPasswordEdits[1].addTextChangedListener(this); break; case ACTION_RESET_PWD: int ids[] = { R.id.et_cur_pwd, R.id.et_password, R.id.et_confirm }; for (int i = 0; i < ids.length; ++i) { mPasswordEdits[i] = (EditText) rootView.findViewById(ids[i]); mPasswordEdits[i].addTextChangedListener(this); } break; case ACTION_CREDITS: rootView.findViewById(R.id.cancel).setOnClickListener(this); TextView tv = (TextView) rootView.findViewById(R.id.testers); tv.setText(R.string.cc_yhc); tv = (TextView) rootView.findViewById(R.id.translators); String translators = String.format(Locale.getDefault(), "%s: %s\n%s: %s\n%s: %s", getString(R.string.lang_fr), getString(R.string.cc_xcx), getString(R.string.lang_es), getString(R.string.cc_jh), getString(R.string.lang_zhtw), getString(R.string.cc_qqz)); tv.setText(translators); break; case ACTION_LICENSE: WebView wv = (WebView) rootView.findViewById(R.id.licence_page); wv.loadUrl("file:///android_asset/licence.html"); break; } return rootView; }
From source file:org.otempo.view.StationActivity.java
/** * Llamado por el manager cuando cambiamos de estacin por GPS *//*from w w w.ja v a 2 s .c o m*/ @Override public void onStationChanged(final @NonNull Station station) { Log.d("OTempo", "onStationChanged"); runOnUiThread(new Runnable() { @Override public void run() { fillStationAdapter(); Spinner stationSpinner = findViewById(R.id.stationSpinner); stationSpinner.setSelection(_stationAdapter.getPosition(station)); updateLayout(); } }); }