List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource)
From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java
/** * Display the details for a given stop//from w ww.j a va2 s . c o m * @param stop */ private void displayStop(Stop stop) { // Set labels from Stop hash map String firstLineText = stop.getPrimaryName(); String secondLineText = "Stop " + stop.getFlagStopNumber(); // If the stop has a secondary name, add it if (stop.getSecondaryName().length() > 0) { secondLineText += ": " + stop.getSecondaryName(); } secondLineText += " - " + stop.getCityDirection(); secondLineText += " (" + stop.getTramTrackerID() + ")"; //initialiseDatabase(); final List<Route> mRoutes = mDB.getRoutesForStop(mTramTrackerId); stop.setRoutes(mRoutes); String thirdLineText = stop.getRoutesString(); ((TextView) findViewById(R.id.stopNameTextView)).setText(firstLineText); ((TextView) findViewById(R.id.stopDetailsTextView)).setText(secondLineText); ((TextView) findViewById(R.id.stopRoutesTextView)).setText(thirdLineText); // If we have more than one route for this stop, then show the spinner if (mRoutes.size() > 1) { mRoutesSpinner = (Spinner) findViewById(R.id.routeSelectSpinner); mRoutesSpinner.setVisibility(View.VISIBLE); mAdapterForSpinner = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item); mAdapterForSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mRoutesSpinner.setAdapter(mAdapterForSpinner); // Add 'All' mAdapterForSpinner.add("All Routes"); Route r; for (int i = 0; i < mRoutes.size(); i++) { r = mRoutes.get(i); mAdapterForSpinner.add("Route " + r.getNumber()); // If we have a route already (e.g. passed from Favourites activity, then // select it right now if (mRoute != null) { if (mRoute.getId() == r.getId()) { // i+1 because we have 'All Route' in position 0 mRoutesSpinner.setSelection(i + 1); } } } mRoutesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (id == 0) { mRoute = null; } else { // -1 for the offset of having 'All Routes' first item mRoute = mRoutes.get(position - 1); if (LOGV) Log.v(TAG, "Route selected: " + mRoute); } // Refresh the results mStarButton.setChecked(mFavouriteList.isFavourite(new Favourite(mStop, mRoute))); mShowDialog = true; new GetNextTramTimes().execute(); } public void onNothingSelected(AdapterView<?> parent) { mRoute = null; } }); } }
From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java
private void update_station_autocomplete(int id) { ArrayAdapter<String> stations = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); Cursor c = mDbHelper.fetch_stations(); if (c.moveToFirst()) do {//w w w . j a va2 s . c om stations.add(c.getString(c.getColumnIndex(DbAdapter.KEY_STN))); } while (c.moveToNext()); c.close(); AutoCompleteTextView stations_entry = (AutoCompleteTextView) findViewById(id); stations_entry.setThreshold(1); stations_entry.setAdapter(stations); }
From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java
private void update_agent_autocomplete(int id) { ArrayAdapter<String> agents = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); Cursor c = mDbHelper.fetch_agents(); if (c.moveToFirst()) do {// ww w .j a va 2 s . c om agents.add(c.getString(c.getColumnIndex(DbAdapter.KEY_AGENT))); } while (c.moveToNext()); c.close(); AutoCompleteTextView agents_entry = (AutoCompleteTextView) findViewById(id); agents_entry.setThreshold(1); agents_entry.setAdapter(agents); }
From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java
private void update_operator_autocomplete(int id) { ArrayAdapter<String> operators = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); Cursor c = mDbHelper.fetch_operators(); if (c.moveToFirst()) do {/* w w w . j a va 2s .c o m*/ operators.add(c.getString(c.getColumnIndex(DbAdapter.KEY_OPERATOR))); } while (c.moveToNext()); c.close(); AutoCompleteTextView operators_entry = (AutoCompleteTextView) findViewById(id); operators_entry.setThreshold(1); operators_entry.setAdapter(operators); }
From source file:github.popeen.dsub.activity.SubsonicActivity.java
protected void createCustomActionBarView() { actionBarSpinner = (Spinner) getLayoutInflater().inflate(R.layout.actionbar_spinner, null); if ((this instanceof SubsonicFragmentActivity || this instanceof SettingsActivity) && (Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_COLOR_ACTION_BAR, true) || ThemeUtil.getThemeRes(this) != R.style.Theme_DSub_Light_No_Color)) { actionBarSpinner.setBackgroundDrawable(DrawableTint.getTintedDrawableFromColor(this, R.drawable.abc_spinner_mtrl_am_alpha, android.R.color.white)); }/*from w ww.j a v a 2s . c om*/ spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); actionBarSpinner.setOnItemSelectedListener(this); actionBarSpinner.setAdapter(spinnerAdapter); getSupportActionBar().setCustomView(actionBarSpinner); }
From source file:com.googlecode.CallerLookup.Main.java
@SuppressWarnings("unchecked") public void updateLookupEntries() { parseLookupEntries();/* www .j ava2 s .c o m*/ ArrayAdapter<CharSequence> adapter = (ArrayAdapter<CharSequence>) mLookup.getAdapter(); if (adapter == null) { adapter = new ArrayAdapter<CharSequence>(getApplicationContext(), android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mLookup.setAdapter(adapter); } else { adapter.clear(); } adapter.add("Custom"); for (String lookupEntryName : mLookupEntries.keySet()) { adapter.add(lookupEntryName); } for (String lookupEntryName : mUserLookupEntries.keySet()) { assert (!mLookupEntries.containsKey(lookupEntryName)); mLookupEntries.put(lookupEntryName, mUserLookupEntries.get(lookupEntryName)); adapter.add(lookupEntryName); } String name = mPrefs.getString(PREFS_LOOKUP, "Custom"); if ((name.length() > 0) && !name.equals("Custom")) { int count = mLookup.getCount(); for (int i = 1; i < count; i++) { if (mLookup.getItemAtPosition(i).toString().equals(name)) { mLookup.setSelection(i); break; } } } else { if (mLookup.getSelectedItemPosition() != 0) { mIgnoreItemSelection = true; mLookup.setSelection(0); } } }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityAddPickupAndDropoff.java
/** * Initialize the {@link AutoCompleteTextView}'s with an {@link ArrayAdapter} * and a listener ({@link AutoCompleteTextWatcher}). The listener gets autocomplete * data from the Google Places API and updates the ArrayAdapter with these. */// w w w. j a va2 s. c om private void initAutocomplete() { adapter = new ArrayAdapter<String>(this, R.layout.item_list); adapter.setNotifyOnChange(true); acPickup = (AutoCompleteTextView) findViewById(R.id.pickupText); acPickup.setAdapter(adapter); acPickup.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acPickup)); acPickup.setThreshold(1); acPickup.selectAll(); acDropoff = (AutoCompleteTextView) findViewById(R.id.dropoffText); acDropoff.setAdapter(adapter); acDropoff.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acDropoff)); //sets the next button on the keyboard acPickup.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { // Sets the pickup location setPickupLocation(); // Sets focus to dropoff acDropoff.requestFocus(); return true; } else { return false; } } }); //sets the done button on the keyboard acDropoff.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { // Sets the dropoff location setDropOffLocation(); // Sets focus to "Comment to driver" ((EditText) findViewById(R.id.mapViewPickupEtComment)).requestFocus(); return true; } else { return false; } } }); }
From source file:com.doplgangr.secrecy.settings.SettingsFragment.java
void choosePath(final getFileListener listener) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(context); builderSingle.setTitle(context.getString(R.string.Settings__select_storage_title)); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, R.layout.select_dialog_singlechoice); final Map<String, File> storages = Util.getAllStorageLocations(); for (String key : storages.keySet()) { arrayAdapter.add(key);//from w w w . j a va 2s . co m } builderSingle.setNegativeButton(R.string.CANCEL, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); File file = storages.get(strName); listener.get(file); } }); builderSingle.show(); }
From source file:com.cssweb.android.base.DialogActivity.java
private void setAdapter(Spinner timeSpinner, String[] params) { ArrayAdapter<String> timeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item); timeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Log.i("=================", ">>>>>>>>>>>>>>>>>>>>>>>>"+params); for (String param : params) { timeAdapter.add(param);/*from w w w . j a v a 2 s . c om*/ } timeSpinner.setAdapter(timeAdapter); }
From source file:com.kjsaw.alcosys.ibacapp.IBAC.java
private void InitializeUI() { // Set up the window layout //requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main);// w w w .ja v a 2 s. c om //getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); // Set up ui TextView mHeader = (TextView) findViewById(R.id.mth); mHeader.setText(R.string.header); logDebug = (TextView) findViewById(R.id.debug_ascii); TextView mFooter = (TextView) findViewById(R.id.mtf); mFooter.setText(R.string.footer); _conversationArrayAdapterBottom = new ArrayAdapter<String>(this, R.layout.message); // Initialize the array adapter for the conversation thread _conversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message); _conversationView = (ListView) findViewById(R.id.in); // _conversationView.setAdapter(_conversationArrayAdapter); _conversationArrayAdapter.clear(); _conversationViewBottom = (ListView) findViewById(R.id.in2); _conversationViewBottom.setAdapter(_conversationArrayAdapterBottom); _conversationArrayAdapterBottom.clear(); _title = (TextView) findViewById(R.id.title_left_text); _title = (TextView) findViewById(R.id.title_right_text); _textCountdown = (TextView) findViewById(R.id.text_countdown); textViewAppVersion = (TextView) findViewById(R.id.text_app_version); showAppVersion(); initialCamera(); }