List of usage examples for android.widget ArrayAdapter createFromResource
public static @NonNull ArrayAdapter<CharSequence> createFromResource(@NonNull Context context, @ArrayRes int textArrayResId, @LayoutRes int textViewResId)
From source file:ca.liquidlabs.android.speedtestvisualizer.activities.MapperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get feature to show progress in actionbar when processing data requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_mapper); // It seems like 4.0.x enables progress by default - STOP it! hideProgressIndicator();/*ww w.ja va2 s. com*/ Spinner spinner = (Spinner) findViewById(R.id.spinner_conntype_filter); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.filters_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new ConnectionTypeFilterHandler()); // Show the Up button in the action bar. setupActionBar(); setUpMapIfNeeded(); }
From source file:org.noise_planet.noisecapture.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); initDrawer();/*w ww. ja va2s.co 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:eu.power_switch.gui.dialog.DeveloperOptionsDialog.java
@NonNull @Override//ww w . j a v a 2 s . c o 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:de.uhrenbastler.watchcheck.ui.LogDialog.java
public LogDialog(Context context, Bundle logData) { super(context); setContentView(R.layout.log_dialog); setTitle(getContext().getString(R.string.enterLog)); setCancelable(true);//from w w w.ja v a 2s. c o m Button buttonSave = (Button) findViewById(R.id.buttonSave); buttonSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { makeLogEntry(); saved = true; dismiss(); } }); watchId = logData.getInt(ATTR_WATCH_ID); deviation = logData.getDouble(ATTR_DEVIATION); modeNtp = logData.getBoolean(ATTR_MODE_NTP); localTime = (GregorianCalendar) logData.get(ATTR_LOCAL_TIME); ntpTime = (GregorianCalendar) logData.get(ATTR_NTP_TIME); lastLog = (Log) logData.get(ATTR_LAST_LOG); Logger.debug("watchId=" + watchId + ", deviation=" + deviation + ", modeNtp=" + modeNtp + ", localTime=" + localTime.getTime() + ", ntpTime=" + (ntpTime != null ? ntpTime.getTime() : "NULL") + ", lastLog=" + lastLog); TextView textDeviation = (TextView) findViewById(R.id.textViewDeviationValue); DecimalFormat df = new DecimalFormat("#.#"); textDeviation.setText( (deviation > 0 ? "+" : deviation < 0 ? "-" : "+-") + df.format(Math.abs(deviation)) + " sec."); positionSpinner = (Spinner) findViewById(R.id.logSpinnerPosition); ArrayAdapter<?> positionAdapter = ArrayAdapter.createFromResource(getContext(), R.array.positions, android.R.layout.simple_spinner_item); positionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); positionSpinner.setAdapter(positionAdapter); if (lastLog != null && lastLog.getPosition() != null) positionSpinner.setSelection(ArrayUtils.indexOf(POSITIONARR, lastLog.getPosition())); else positionSpinner.setSelection(0); temperatureSpinner = (Spinner) findViewById(R.id.logSpinnerTemperature); ArrayAdapter<?> temperatureAdapter = ArrayAdapter.createFromResource(getContext(), R.array.temperatures, android.R.layout.simple_spinner_item); temperatureAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); temperatureSpinner.setAdapter(temperatureAdapter); if (lastLog != null) temperatureSpinner.setSelection(ArrayUtils.indexOf(TEMPARR, lastLog.getTemperature())); else temperatureSpinner.setSelection(0); comment = (EditText) findViewById(R.id.logComment); startFlag = (CheckBox) findViewById(R.id.logCheckBoxNewPeriod); startFlag.setChecked(lastLog == null); startFlag.setEnabled(lastLog != null); }
From source file:ru.cityvoicer.golosun.RegistrationFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.genders, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mGenderSpinner.setAdapter(adapter);/*from ww w . jav a2 s .c o m*/ updateStatus(); }
From source file:com.streaming.sweetplayer.fragment.ArtistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mDataBase = new DataBaseHelper(mActivity); if (Utils.isConnectedToInternet(mActivity)) { mListView = (ListView) mActivity.findViewById(R.id.detail_list); mScrollLayout = (LinearLayout) mActivity.findViewById(R.id.scroll_layout); mSpinnerAdapter = ArrayAdapter.createFromResource(mActivity, R.array.artist_detail_array, android.R.layout.simple_spinner_item); mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinner = (Spinner) mActivity.findViewById(R.id.detail_spinner); mSpinner.setAdapter(mSpinnerAdapter); mSpinner.setOnItemSelectedListener(this); mArtistNameTextView = (TextView) mActivity.findViewById(R.id.detail_artist_name); mArtistNameTextView.setText(artistName); mAlbumNameTextView = (TextView) mActivity.findViewById(R.id.detail_album_name); mImageLoader = new ImageLoader(mActivity.getApplicationContext()); mImageLoader.setResize(true);/*ww w . ja v a2 s . com*/ mArtistImageView = (ImageView) mActivity.findViewById(R.id.detail_artist_image); mArtistImageView.setVisibility(View.VISIBLE); mImageLoader.DisplayImage(artistImage, mArtistImageView); mJsonItem = Config.SONGS_ITEM; mImageForDB = Utils.replaceImage(artistImage, 1); // Log.d(TAG, "Artist: " + artistSongsUrl + "-" + artistAlbumsUrl + "-" + artistImage + "-" + artistName); clearAllData(); new GetSongsTask().execute(mArtistSongsList, artistSongsUrl, true); } else { Utils.showAlertDialog(mActivity, getString(R.string.no_internet_title), getString(R.string.no_internet_message)); } }
From source file:com.bms.mqp.behaviormodelsystem.AppUsageStatisticsFragment.java
@Override public void onViewCreated(View rootView, Bundle savedInstanceState) { super.onViewCreated(rootView, savedInstanceState); mUsageListAdapter = new UsageStatsListAdapter(); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_app_usage); mLayoutManager = mRecyclerView.getLayoutManager(); mRecyclerView.scrollToPosition(0);// w w w .ja va 2 s.com mRecyclerView.setAdapter(mUsageListAdapter); mOpenUsageSettingButton = (Button) rootView.findViewById(R.id.button_open_usage_setting); SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.action_list, android.R.layout.simple_spinner_dropdown_item); }
From source file:es.farfuteam.vncpp.controller.NewConnectionActivity.java
/** * @param savedInstanceState//www . j a v a 2s. co m * @brief This is the onCreate method * @details The onCreate method adds buttons and edittext on the activity */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.connection_window); ConnectionName_field = (EditText) findViewById(R.id.ConnectionName_inserted); IP_field = (EditText) findViewById(R.id.IP_inserted); PORT_field = (EditText) findViewById(R.id.PORT_inserted); PSW_field = (EditText) findViewById(R.id.PSW_inserted); //desplegable seleccion de colores ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.color_array, android.R.layout.simple_spinner_item); Spinner_colors = (Spinner) findViewById(R.id.Spinner_colors); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner_colors.setAdapter(adapter); Spinner_colors.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, android.view.View v, int position, long id) { setColor_format(getPosEnumQuality(position)); } public void onNothingSelected(AdapterView<?> parent) { //por defecto se selecciona la posicion 0, 24-bit color(extra-high) setColor_format(QualityArray.SuperHigh); } }); Button botonConnect = (Button) findViewById(R.id.buttonConnect); botonConnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //primero se verifica que los campos se rellenan bien, //y se aade a la BD antes de iniciar Canvas. if (verify(v)) { //crear usuario si todo ha ido bien createNewConnection(); iniCanvasActivity(); } } }); Button botonCancel = (Button) findViewById(R.id.buttonCancel); botonCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Cancel(v); } }); //efectos del actionBar final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); }
From source file:mp.paschalis.BookSearch.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_book_search); getSupportActionBar().setDisplayHomeAsUpEnabled(true); app = (App) getApplication();/*from w ww . j ava2s . c o m*/ linearLayoutSearchLayout = (LinearLayout) findViewById(R.id.linearLayoutSearchLayout); editTextSearchKeyword = (EditText) findViewById(R.id.editTextSearchKeyword); spinnerColumnSelect = (Spinner) findViewById(R.id.spinnerSearchSelectColumn); buttonSearch = (Button) findViewById(R.id.buttonSearchBookSearch); progressBarSearchButton = (ProgressBar) findViewById(R.id.progressBarSearchSearchButton); listViewBookResults = (ListView) findViewById(R.id.listViewBookResults); textViewSearchResults = (TextView) findViewById(R.id.textViewSearchSearchResults); // Create adapter for the Spinner adapterSearchColumns = ArrayAdapter.createFromResource(this, R.array.ArraySearchColumns, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterSearchColumns.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerColumnSelect.setAdapter(adapterSearchColumns); isItemChecked = false; // When button is pressed buttonSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dataClassSearch = new DataClassSearch(); dataClassSearch.column = getResources().getStringArray( R.array.ArraySearchColumnValues)[spinnerColumnSelect.getSelectedItemPosition()]; dataClassSearch.keyword = editTextSearchKeyword.getText().toString(); // Re-init results searchResultBooks = new ArrayList<Book>(); new AsyncTaskBookSearch().execute(dataClassSearch); } }); // When results is chosen listViewBookResults.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { app.selectedBook = (Book) (listViewBookResults.getItemAtPosition(pos)); listViewBookResults.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listViewBookResults.setItemChecked(pos, true); isItemChecked = true; // REcreate the menu invalidateOptionsMenu(); // linearLayoutSelectedBooks.setVisibility(View.VISIBLE); // // textViewMyBookSelected.setText(selectedBook.title); } }); }
From source file:fr.mixit.android.ui.MembersActivity.java
@Override protected void onCreate(Bundle savedStateInstance) { super.onCreate(savedStateInstance); mMode = getIntent().getIntExtra(EXTRA_DISPLAY_MODE, DISPLAY_MODE_SPEAKERS); if (savedStateInstance != null) { mMode = savedStateInstance.getInt(STATE_DISPLAY_MODE, DISPLAY_MODE_SPEAKERS); }/*from w w w . j a va 2 s . c om*/ final String memberName = getIntent().getStringExtra(EXTRA_MEMBER_NAME); switch (mMode) { case DISPLAY_MODE_SPONSORS: getSupportActionBar().setTitle(R.string.sponsors); getSupportActionBar().setDisplayShowTitleEnabled(true); break; case DISPLAY_MODE_LINKS: getSupportActionBar().setTitle(getString(R.string.members_links, memberName)); getSupportActionBar().setDisplayShowTitleEnabled(true); break; case DISPLAY_MODE_LINKERS: getSupportActionBar().setTitle(getString(R.string.members_linkers, memberName)); getSupportActionBar().setDisplayShowTitleEnabled(true); break; case DISPLAY_MODE_ALL_MEMBERS: case DISPLAY_MODE_SPEAKERS: case DISPLAY_MODE_STAFF: final Context context = getSupportActionBar().getThemedContext(); final ArrayAdapter<CharSequence> listAdapter = ArrayAdapter.createFromResource(context, R.array.members, R.layout.sherlock_spinner_item); listAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setListNavigationCallbacks(listAdapter, this); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setDisplayShowTitleEnabled(false); break; default: break; } final FragmentManager fm = getSupportFragmentManager(); mMembersListFrag = (MembersListFragment) fm.findFragmentByTag(MembersListFragment.TAG); if (mMembersListFrag == null) { mMembersListFrag = MembersListFragment.newInstance(getIntent()); fm.beginTransaction().add(R.id.content_members_list, mMembersListFrag, MembersListFragment.TAG) .commit(); } if (mMode != DISPLAY_MODE_LINKS && mMode != DISPLAY_MODE_LINKERS && mMode != DISPLAY_MODE_SPONSORS) { int itemSelected = 0; switch (mMode) { case DISPLAY_MODE_ALL_MEMBERS: itemSelected = 0; break; case DISPLAY_MODE_SPEAKERS: itemSelected = 1; break; default: itemSelected = 0; break; } getSupportActionBar().setSelectedNavigationItem(itemSelected); } mMembersListFrag.setDisplayMode(mMode); if (UIUtils.isTablet(this)) { mMemberDetailsFrag = (MemberDetailsFragment) fm.findFragmentByTag(MemberDetailsFragment.TAG); if (mMemberDetailsFrag == null) { mMemberDetailsFrag = MemberDetailsFragment.newInstance(getIntent()); fm.beginTransaction() .add(R.id.content_member_details, mMemberDetailsFrag, MemberDetailsFragment.TAG).commit(); } } }