List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource)
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.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. *//*from w w w . j a va 2 s. c o m*/ private void initAutocomplete() { adapter = new ArrayAdapter<String>(this, R.layout.item_list); adapter.setNotifyOnChange(true); acFrom = (AutoCompleteTextView) findViewById(R.id.etGoingFrom); acFrom.setAdapter(adapter); acFrom.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acFrom)); acFrom.setThreshold(1); acTo = (AutoCompleteTextView) findViewById(R.id.etGoingTo); acTo.setAdapter(adapter); acTo.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acTo)); acTo.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); final Button button = ((Button) findViewById(R.id.btnChooseRoute)); if (actionId == EditorInfo.IME_ACTION_DONE) { if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == true) { button.setEnabled(true); button.setText("Next"); return true; } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { mapView.getOverlays().clear(); createMap(); button.setEnabled(true); button.setText("Next"); return true; } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { button.setText("Show on map"); button.setEnabled(false); return false; } else { button.setText("Show on map"); button.setEnabled(false); return false; } } return false; } }); }
From source file:com.google.example.eightbitartist.DrawingActivity.java
/** * Set the list of words to display for guessing. *///from w w w .ja v a 2s .co m private void resetWords(List<String> words) { ListView list = (ListView) findViewById(R.id.listView); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); for (String st : words) { adapter.add(st); } list.setAdapter(adapter); }