List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.google.android.apps.muzei.settings.SettingsActivity.java
private void setupAppBar() { mAppBar = (Toolbar) findViewById(R.id.app_bar); mAppBar.setNavigationOnClickListener(new View.OnClickListener() { @Override/*from www .j a va2 s.co m*/ public void onClick(View view) { onNavigateUp(); } }); final LayoutInflater inflater = LayoutInflater.from(this); Spinner sectionSpinner = (Spinner) findViewById(R.id.section_spinner); sectionSpinner.setAdapter(new BaseAdapter() { @Override public int getCount() { return SECTION_LABELS.length; } @Override public Object getItem(int position) { return SECTION_LABELS[position]; } @Override public long getItemId(int position) { return position + 1; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item, parent, false); } ((TextView) convertView.findViewById(android.R.id.text1)) .setText(getString(SECTION_LABELS[position])); return convertView; } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item_dropdown, parent, false); } ((TextView) convertView.findViewById(android.R.id.text1)) .setText(getString(SECTION_LABELS[position])); return convertView; } }); sectionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> spinner, View view, int position, long id) { Class<? extends Fragment> fragmentClass = SECTION_FRAGMENTS[position]; Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_container); if (currentFragment != null && fragmentClass.equals(currentFragment.getClass())) { return; } inflateMenuFromFragment(0); try { Fragment newFragment = fragmentClass.newInstance(); getSupportFragmentManager().beginTransaction() .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .setTransitionStyle(R.style.Muzei_SimpleFadeFragmentAnimation) .replace(R.id.content_container, newFragment).commitAllowingStateLoss(); } catch (Exception e) { throw new RuntimeException(e); } } @Override public void onNothingSelected(AdapterView<?> spinner) { } }); sectionSpinner.setSelection(mStartSection); inflateMenuFromFragment(0); mAppBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_get_more_sources: try { Intent playStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/search?q=Muzei&c=apps")) .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); preferPackageForIntent(SettingsActivity.this, playStoreIntent, PLAY_STORE_PACKAGE_NAME); startActivity(playStoreIntent); } catch (ActivityNotFoundException activityNotFoundException1) { Toast.makeText(SettingsActivity.this, R.string.play_store_not_found, Toast.LENGTH_LONG) .show(); } return true; case R.id.action_about: startActivity(new Intent(SettingsActivity.this, AboutActivity.class)); return true; } Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_container); if (currentFragment != null && currentFragment instanceof SettingsActivityMenuListener) { ((SettingsActivityMenuListener) currentFragment).onSettingsActivityMenuItemClick(item); } return false; } }); }
From source file:com.example.travelclaims.NewExpenseActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addnewexpense); DateView = (EditText) findViewById(R.id.editDate); final Spinner categoryspinner = (Spinner) findViewById(R.id.categoryspinner); ArrayAdapter<CharSequence> categoryadapter = ArrayAdapter.createFromResource(this, R.array.category_array, android.R.layout.simple_spinner_item); categoryadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); categoryspinner.setAdapter(categoryadapter); final Spinner currencyspinner = (Spinner) findViewById(R.id.currencyspinner); ArrayAdapter<CharSequence> currencyadapter = ArrayAdapter.createFromResource(this, R.array.currency_array, android.R.layout.simple_spinner_item); currencyadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); currencyspinner.setAdapter(currencyadapter); currencyspinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override/*from ww w . jav a 2 s.c o m*/ public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { currency = currencyspinner.getSelectedItem().toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); categoryspinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { category = categoryspinner.getSelectedItem().toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); set_on_click(); }
From source file:com.gsma.rcs.provisioning.local.ProfileProvisioning.java
@Override public void displayRcsSettings() { if (sLogger.isActivated()) { sLogger.debug("displayRcsSettings"); }/*w w w .j a va 2s . 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:br.com.frs.foodrestrictions.FoodMessages.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_restriction_message, container, false); restrictList = foodIconList.getFoodRestrictionList(true); llAllergic = (LinearLayout) v.findViewById(R.id.llAllergic); llDontEat = (LinearLayout) v.findViewById(R.id.llDontEat); allergicText = (TextView) v.findViewById(R.id.messages_allergic_text); dontEatText = (TextView) v.findViewById(R.id.messages_dont_eat_text); Spinner spinner = (Spinner) v.findViewById(R.id.spinner_language); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(v.getContext(), R.array.languages_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(this); return v;//w ww. j av a 2 s . co m }
From source file:com.gsma.rcs.provisioning.local.ServiceProvisioning.java
@Override public void displayRcsSettings() { mHelper.setLongEditText(R.id.MaxPhotoIconSize, RcsSettingsData.MAX_PHOTO_ICON_SIZE); mHelper.setIntEditText(R.id.MaxFreetextLength, RcsSettingsData.MAX_FREETXT_LENGTH); mHelper.setIntEditText(R.id.MaxChatParticipants, RcsSettingsData.MAX_CHAT_PARTICIPANTS); mHelper.setIntEditText(R.id.MaxChatMessageLength, RcsSettingsData.MAX_CHAT_MSG_LENGTH); mHelper.setIntEditText(R.id.MaxGroupChatMessageLength, RcsSettingsData.MAX_GROUPCHAT_MSG_LENGTH); mHelper.setLongEditText(R.id.ChatIdleDuration, RcsSettingsData.CHAT_IDLE_DURATION); mHelper.setLongEditText(R.id.MaxFileTransferSize, RcsSettingsData.MAX_FILE_TRANSFER_SIZE); mHelper.setLongEditText(R.id.WarnFileTransferSize, RcsSettingsData.WARN_FILE_TRANSFER_SIZE); mHelper.setLongEditText(R.id.MaxImageShareSize, RcsSettingsData.MAX_IMAGE_SHARE_SIZE); mHelper.setLongEditText(R.id.MaxVideoShareDuration, RcsSettingsData.MAX_VIDEO_SHARE_DURATION); mHelper.setLongEditText(R.id.MaxAudioMessageDuration, RcsSettingsData.MAX_AUDIO_MESSAGE_DURATION); mHelper.setIntEditText(R.id.MaxChatSessions, RcsSettingsData.MAX_CHAT_SESSIONS); mHelper.setIntEditText(R.id.MaxFileTransferSessions, RcsSettingsData.MAX_FILE_TRANSFER_SESSIONS); mHelper.setIntEditText(R.id.MaxConcurrentOutgoingFileTransferSessions, RcsSettingsData.MAX_CONCURRENT_OUTGOING_FILE_TRANSFERS); mHelper.setIntEditText(R.id.MaxIpCallSessions, RcsSettingsData.MAX_IP_CALL_SESSIONS); mHelper.setIntEditText(R.id.MaxChatLogEntries, RcsSettingsData.MAX_CHAT_LOG_ENTRIES); mHelper.setIntEditText(R.id.MaxRichcallLogEntries, RcsSettingsData.MAX_RICHCALL_LOG_ENTRIES); mHelper.setIntEditText(R.id.MaxIpcallLogEntries, RcsSettingsData.MAX_IPCALL_LOG_ENTRIES); mHelper.setStringEditText(R.id.DirectoryPathPhotos, RcsSettingsData.DIRECTORY_PATH_PHOTOS); mHelper.setStringEditText(R.id.DirectoryPathVideos, RcsSettingsData.DIRECTORY_PATH_VIDEOS); mHelper.setStringEditText(R.id.DirectoryPathAudios, RcsSettingsData.DIRECTORY_PATH_AUDIOS); mHelper.setStringEditText(R.id.DirectoryPathFiles, RcsSettingsData.DIRECTORY_PATH_FILES); mHelper.setStringEditText(R.id.DirectoryPathFileIcons, RcsSettingsData.DIRECTORY_PATH_FILEICONS); mHelper.setIntEditText(R.id.MaxGeolocLabelLength, RcsSettingsData.MAX_GEOLOC_LABEL_LENGTH); mHelper.setLongEditText(R.id.GeolocExpirationTime, RcsSettingsData.GEOLOC_EXPIRATION_TIME); mHelper.setLongEditText(R.id.CallComposerIdleDuration, RcsSettingsData.CALL_COMPOSER_INACTIVITY_TIMEOUT); Spinner spinner = (Spinner) mRootView.findViewById(R.id.ImSessionStart); ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, IM_SESSION_START_MODES);// w ww .ja v a 2s. co m adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); setSpinnerParameter(spinner, RcsSettingsData.IM_SESSION_START, true, IM_SESSION_START_MODES); mHelper.setBoolCheckBox(R.id.SmsFallbackService, RcsSettingsData.SMS_FALLBACK_SERVICE); mHelper.setBoolCheckBox(R.id.StoreForwardServiceWarning, RcsSettingsData.WARN_SF_SERVICE); mHelper.setBoolCheckBox(R.id.AutoAcceptFileTransfer, RcsSettingsData.AUTO_ACCEPT_FILE_TRANSFER); mHelper.setBoolCheckBox(R.id.AutoAcceptFileTransferInRoaming, RcsSettingsData.AUTO_ACCEPT_FT_IN_ROAMING); mHelper.setBoolCheckBox(R.id.AutoAcceptFileTransferChangeable, RcsSettingsData.AUTO_ACCEPT_FT_CHANGEABLE); mHelper.setBoolCheckBox(R.id.AutoAcceptChat, RcsSettingsData.AUTO_ACCEPT_CHAT); mHelper.setBoolCheckBox(R.id.AutoAcceptGroupChat, RcsSettingsData.AUTO_ACCEPT_GROUP_CHAT); mHelper.setBoolCheckBox(R.id.EnrichCalling, RcsSettingsData.ENRICH_CALLING_SERVICE); }
From source file:se.hockersten.timed.vibration.main.PracticeTab.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.main_practice, container, false); Spinner spinFirst = (Spinner) root.findViewById(R.id.mainPractice_spinIntervalFirst); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.time_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinFirst.setAdapter(adapter); Spinner spinSecond = (Spinner) root.findViewById(R.id.mainPractice_spinIntervalSecond); ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(getActivity(), R.array.time_array, android.R.layout.simple_spinner_item); adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinSecond.setAdapter(adapter2);//from w w w .j ava 2 s.c o m if (savedInstanceState != null) { counting = savedInstanceState.getBoolean(COUNTING); } return root; }
From source file:com.micabyte.android.app.BaseFragment.java
@SuppressWarnings("ConstantConditions") protected Spinner setSpinner(int resId, int arrId, int sp_it, int sp_dd) { final Spinner s = (Spinner) getView().findViewById(resId); final ArrayAdapter<CharSequence> adapter = ArrayAdapter .createFromResource(getActivity().getApplicationContext(), arrId, sp_it); adapter.setDropDownViewResource(sp_dd); s.setAdapter(adapter); return s;// w w w . j a v a 2 s . c om }
From source file:org.noise_planet.noisecapture.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); initDrawer();/*from w w w .jav a2 s . c o m*/ this.measurementManager = new MeasurementManager(getApplicationContext()); Intent intent = getIntent(); if (intent != null && intent.hasExtra(RESULTS_RECORD_ID)) { record = measurementManager.getRecord(intent.getIntExtra(RESULTS_RECORD_ID, -1)); } else { // Read the last stored record List<Storage.Record> recordList = measurementManager.getRecords(); if (!recordList.isEmpty()) { record = recordList.get(0); } else { // Message for starting a record Toast.makeText(getApplicationContext(), getString(R.string.no_results), Toast.LENGTH_LONG).show(); return; } } // Fill the spinner_map Spinner spinner = (Spinner) findViewById(R.id.spinner_map); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.choice_user_map, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new MapDropDownChooseListener(this)); // Display the map setUpMapIfNeeded(); }
From source file:com.google.maps.android.utils.demo.HeatmapsDemoActivity.java
@Override protected void startDemo() { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-25, 143), 4)); // Set up the spinner/dropdown list Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.heatmaps_datasets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new SpinnerActivity()); try {//w ww.ja v a2 s. c om mLists.put(getString(R.string.police_stations), new DataSet(readItems(R.raw.police), getString(R.string.police_stations_url))); mLists.put(getString(R.string.medicare), new DataSet(readItems(R.raw.medicare), getString(R.string.medicare_url))); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } // Make the handler deal with the map // Input: list of WeightedLatLngs, minimum and maximum zoom levels to calculate custom // intensity from, and the map to draw the heatmap on // radius, gradient and opacity not specified, so default are used }
From source file:com.battlelancer.seriesguide.ui.FirstRunFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // add button getView().findViewById(R.id.buttonFirstRunAddShow).setOnClickListener(new OnClickListener() { @Override/*www . j av a 2 s . c o m*/ public void onClick(View v) { fireTrackerEvent("Add show"); startActivity(new Intent(getActivity(), AddActivity.class)); setFirstRunDismissed(); } }); // language chooser Spinner spinner = (Spinner) getView().findViewById(R.id.welcome_setuplanguage); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.languages, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnLanguageSelectedListener()); // trakt connect button getView().findViewById(R.id.welcome_setuptrakt).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { fireTrackerEvent("Connect trakt"); Intent i = new Intent(getActivity(), ConnectTraktActivity.class); startActivity(i); } }); // dismiss button View buttonDismiss = getView().findViewById(R.id.buttonFirstRunDismiss); CheatSheet.setup(buttonDismiss); buttonDismiss.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { fireTrackerEvent("Dismiss"); setFirstRunDismissed(); } }); setHasOptionsMenu(true); }