List of usage examples for android.widget ArrayAdapter setDropDownViewResource
public void setDropDownViewResource(@LayoutRes int resource)
Sets the layout resource to create the drop down views.
From source file:com.stanzione.licensesmanagement.ui.CreateContactFragment.java
@Override public void onOperationSuccess(Object returnObject, int operationCode) { Log.d(TAG, "Operation success!"); if (operationCode == CODE_LIST_COMPANY) { companyArrayList = (ArrayList<Company>) returnObject; ArrayList<String> companyNameArrayList = new ArrayList<String>(); for (int i = 0; i < companyArrayList.size(); i++) { companyNameArrayList.add(companyArrayList.get(i).getName()); }/*from w w w . ja v a 2s .c om*/ ArrayAdapter<String> companyAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, companyNameArrayList); companyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); contactCompanyNameSpinner.setAdapter(companyAdapter); } else if (operationCode == CODE_CREATE_CONTACT) { Toast.makeText(getActivity(), "Contact created successfully!", Toast.LENGTH_LONG).show(); } progressBar.setVisibility(View.INVISIBLE); }
From source file:com.example.multi_ndef.frag_wifi.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_wifi, container, false); mSpinner = (Spinner) v.findViewById(R.id.spinner); mSpinner.setOnItemSelectedListener(this); mEditText1 = (EditText) v.findViewById(R.id.editText1); fr = (CNFCInterface) getActivity().getApplication(); WifiManager wifi;//w w w . java 2s . com try { wifi = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); // Get WiFi status WifiInfo info = wifi.getConnectionInfo(); // List available networks wifi.startScan(); List<ScanResult> results; results = wifi.getScanResults(); int array_length = results.size(); int i = 0; String[] values = new String[array_length]; for (ScanResult result : results) { values[i] = result.SSID; i = i + 1; } Set<String> set = new HashSet<String>(); Collections.addAll(set, values); String[] uniques = set.toArray(new String[0]); int length = uniques.length; List<String> SpinnerArray = new ArrayList<String>(); for (int i1 = 1; i1 < length; i1++) { SpinnerArray.add(uniques[i1]); } // Create an ArrayAdapter using the string array and a default ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_spinner_item, SpinnerArray); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner mSpinner.setAdapter(adapter); } catch (Exception e) { Toast toast = Toast.makeText(getActivity().getApplicationContext(), "Turn on the wifi", Toast.LENGTH_SHORT); toast.show(); } return v; }
From source file:com.example.weiranfang.healthmonitoranalysis2014.HeatMapActivity.java
@Override protected void startDemo() { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40, -95), 2.8f)); // 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);//from w ww. j av a 2 s. c o m spinner.setOnItemSelectedListener(new SpinnerActivity()); try { JSONArray jsonArray = new GenerateJSONArrayTask().execute(new JSONSender()).get(); mLists.put(getString(R.string.tweet_heat_map), new DataSet(readItems(jsonArray), 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(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } // 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.blogspot.marioboehmer.thingibrowse.ThingResultListActivity.java
private void setUpActionBar() { ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.sherlock_spinner_item, thingsCategoryNames);/* w ww .j a va 2 s . c o m*/ adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setListNavigationCallbacks(adapter, this); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); }
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);/*w w w. j a v a 2 s . c o m*/ return s; }
From source file:at.ac.uniklu.mobile.sportal.MensaActivity.java
private void refreshActionBar() { ArrayAdapter<Mensa> mensaAdapter = new ArrayAdapter<Mensa>(MensaActivity.this, R.layout.actionbar_simple_spinner_item, mMensas); mensaAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mMensaSpinner.setAdapter(mensaAdapter); mMensaSpinner.setSelection(mCurrentMensaIndex); mActionBar.setTitleVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); mMensaSpinner.setVisibility(View.VISIBLE); }
From source file:com.mifos.mifosxdroid.online.CreateNewCenterFragment.java
private void inflateOfficeSpinner() { App.apiManager.getOffices(new Callback<List<Office>>() { @Override/*from w w w. j av a2s . c o m*/ public void success(List<Office> offices, Response response) { final List<String> officeList = new ArrayList<String>(); for (Office office : offices) { officeList.add(office.getName()); officeNameIdHashMap.put(office.getName(), office.getId()); } ArrayAdapter<String> officeAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, officeList); officeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sp_offices.setAdapter(officeAdapter); sp_offices.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { officeId = officeNameIdHashMap.get(officeList.get(i)); Log.d("officeId " + officeList.get(i), String.valueOf(officeId)); if (officeId != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_office), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } @Override public void failure(RetrofitError retrofitError) { } }); }
From source file:com.dgsd.android.ShiftTracker.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar ab = getSupportActionBar(); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.nav_items, R.layout.sherlock_spinner_item); adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); ab.setDisplayShowTitleEnabled(false); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ab.setListNavigationCallbacks(adapter, this); mPrefs = Prefs.getInstance(this); //Show our 'Rate in Market' dialog if needed AppRating.app_launched(this); final int currentJd = TimeUtils.getCurrentJulianDay(); mWeekPagerAdapter = new WeekPagerAdapter(this, getSupportFragmentManager(), currentJd); mMonthPagerAdapter = new MonthPagerAdapter(this, getSupportFragmentManager(), currentJd); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mWeekPagerAdapter); mPager.setOffscreenPageLimit(1);/*w w w. j a va2 s . c o m*/ if (Api.isMin(Api.HONEYCOMB) && !StApp.isFreeApp(this)) { final int animType = Integer.valueOf(mPrefs.get(getString(R.string.settings_key_animation), "0")); ViewPager.PageTransformer transformer = null; switch (animType) { case ANIM_TYPE_INNER_CUBE: transformer = PageTransformerUtils.getInnerCubeTransformer(); break; case ANIM_TYPE_OUTER_CUBE: transformer = PageTransformerUtils.getOuterCubeTransformer(); break; case ANIM_TYPE_TWIST: transformer = PageTransformerUtils.getTwistTransformer(); break; case ANIM_TYPE_COMPRESS: transformer = PageTransformerUtils.getCompressTransformer(); break; } if (transformer != null) mPager.setPageTransformer(false, transformer); } mIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mIndicator.setViewPager(mPager, mWeekPagerAdapter.getPositionForJulianDay(currentJd)); ab.setSelectedNavigationItem(mPrefs.get(KEY_SELECTED_INDEX, 0)); }
From source file:com.idt.ontomedia.geoconsum.NearPlacesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.places_near); //Initialize some values mNearPlaceList = new ArrayList<NearPlace>(); mDistances = getResources().getStringArray(R.array.distances_to_places); mSpinnerTypeOfLocation = (Spinner) findViewById(R.id.spinner1); mSpinnerTypeOfLocation.setOnItemSelectedListener(new OnItemSelectedListener() { @Override/*from www . j a va2s. c o m*/ public void onItemSelected(AdapterView<?> _containerView, View _itemView, int _position, long _id) { getSupportLoaderManager().getLoader(NEAR_PLACES_LOADER_ID).onContentChanged(); } @Override public void onNothingSelected(AdapterView<?> _containerView) { } }); mSpinnerDistances = (Spinner) findViewById(R.id.spinner2); mSpinnerDistances.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> _containerView, View _itemView, int _position, long _id) { getSupportLoaderManager().getLoader(NEAR_PLACES_LOADER_ID).onContentChanged(); } @Override public void onNothingSelected(AdapterView<?> _containerView) { } }); ImageButton buttonUpdate = (ImageButton) findViewById(R.id.buttonUpdate); buttonUpdate.setOnClickListener(new OnClickListener() { @Override public void onClick(View _view) { getSupportLoaderManager().getLoader(NEAR_PLACES_LOADER_ID).onContentChanged(); } }); // Configure the adapter and set the spinner of distances // This is a programatically operation because we can't modify the text color // with the use of "entries" in the xml file. We define an ArrayAdapter and specify the layout of this to avoid // the default layout with the normal text style (black and normal) ArrayAdapter<String> arrayAdapterDistances = new ArrayAdapter<String>(this, R.layout.my_spinner_layout, mDistances); arrayAdapterDistances.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinnerDistances.setAdapter(arrayAdapterDistances); // Configure the adapter and set the spinner of types of Places // This is a programatically operation because we can't modify the text color // with the use of "entries" in the xml file. We define an ArrayAdapter and specify the layout of this to avoid // the default layout with the normal text style (black and normal) mAdapterTypeOfLocation = new SimpleCursorAdapter(this, R.layout.my_spinner_layout, null, COLUMNS_FROM, VIEWS_TO, 0); mAdapterTypeOfLocation.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinnerTypeOfLocation.setAdapter(mAdapterTypeOfLocation); mSpinnerTypeOfLocation.setSelection(mTypeOfLocationPosition, true); //Create the adapter and fill the place list with the real distances mNearPlacesAdapter = new NearPlacesAdapter(this, mNearPlaceList); mListViewNearPlaces = (ListView) findViewById(R.id.listViewNearPlaces); mListViewNearPlaces.setAdapter(mNearPlacesAdapter); mListViewNearPlaces.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> _containerView, View _itemView, int _position, long _id) { Intent intent = new Intent(); intent.setClass(getBaseContext(), PlaceDetailActivity.class); intent.putExtra(ListPlacesFragment.EXTRA_ID_KEY, mNearPlaceList.get(_position).getId()); startActivity(intent); } }); getSupportLoaderManager().initLoader(TYPE_OF_LOCATION_LOADER_ID, null, new TypeOfLocationCursorLoaderCallback()); getSupportLoaderManager().initLoader(NEAR_PLACES_LOADER_ID, null, new NearPlacesCursorLoaderCallback()); }
From source file:com.akhbulatov.wordkeeper.ui.activity.MainActivity.java
private void showWordEditorDialog(@StringRes int titleId, @StringRes int positiveTextId, @StringRes int negativeTextId) { DialogFragment dialog = WordEditorDialog.newInstance(titleId, positiveTextId, negativeTextId); dialog.show(getSupportFragmentManager(), null); // NOTE! If the method is not called, the app crashes getSupportFragmentManager().executePendingTransactions(); Dialog dialogView = dialog.getDialog(); Spinner spinnerCategories = dialogView.findViewById(R.id.spinner_categories); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, mWordListFragment.getCategories()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerCategories.setAdapter(adapter); // Receives and shows data of the selected word to edit in the dialog // Data is the name, translation and category if (positiveTextId == R.string.word_editor_action_edit) { EditText editName = dialogView.findViewById(R.id.edit_word_name); EditText editTranslation = dialogView.findViewById(R.id.edit_word_translation); editName.setText(mWordListFragment.getName()); editTranslation.setText(mWordListFragment.getTranslation()); spinnerCategories.setSelection(adapter.getPosition(mWordListFragment.getCategory())); }// ww w . ja v a2 s . c om }