List of usage examples for android.widget ArrayAdapter add
public void add(@Nullable T object)
From source file:com.todoroo.astrid.activity.FilterListFragment.java
/** Sets up the coach list adapter */ protected void setUpList() { adapter.setListView(getListView());/* ww w . j a v a2 s . co m*/ setListAdapter(adapter); adapter.setLastSelected(mSelectedIndex); // Can't do context menus when list is in popup menu for some reason--workaround if (((AstridActivity) getActivity()).fragmentLayout == AstridActivity.LAYOUT_SINGLE) { getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // Do stuff final Filter filter = adapter.getItem(position); final String[] labels = filter.contextMenuLabels; final Intent[] intents = filter.contextMenuIntents; ArrayAdapter<String> intentAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1); intentAdapter.add(getString(R.string.FLA_context_shortcut)); for (String l : labels) { intentAdapter.add(l); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(filter.title); builder.setAdapter(intentAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { showCreateShortcutDialog(getActivity(), ShortcutActivity.createIntent(filter), filter); } else { startActivityForResult(intents[which - 1], REQUEST_CUSTOM_INTENT); } } }); Dialog d = builder.create(); d.setOwnerActivity(getActivity()); d.show(); return true; } }); } else { registerForContextMenu(getListView()); } }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Account.java
private void selectIdentity() { getDriverIdentity();// w ww . java 2 s . com if (!driver_identity.isEmpty()) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_item); for (String type : driver_identity.keySet()) { arrayAdapter.add(type); } builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @TargetApi(Build.VERSION_CODES.M) @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); progressDialog_loading = ProgressDialog.show(getActivity(), "", "Loading. Please wait...", true); change_driver = driver_mapping_value.get(strName); changeDriverType = driver_identity.get(strName); attributes.put("select driver", strName); sendDataRequest.driverWorkIdentity(change_driver); } }); builderSingle.show(); } }
From source file:org.solovyev.android.calculator.history.AbstractCalculatorHistoryFragment.java
private void updateAdapter() { final List<CalculatorHistoryState> historyList = getHistoryList(); final ArrayAdapter<CalculatorHistoryState> adapter = getAdapter(); try {//from ww w .j av a 2s . com adapter.setNotifyOnChange(false); adapter.clear(); for (CalculatorHistoryState historyState : historyList) { adapter.add(historyState); } } finally { adapter.setNotifyOnChange(true); } adapter.notifyDataSetChanged(); }
From source file:com.example.mapsv2.ClustersAreListsActivity.java
private void showInfo(final int x, int y, final Cluster cluster) { final int orientation = getResources().getConfiguration().orientation; // (re-)Load cluster data into the ListView @SuppressWarnings("unchecked") ArrayAdapter<String> adapter = (ArrayAdapter<String>) listView.getAdapter(); adapter.clear();/*from w ww . ja v a 2s. co m*/ for (Marker m : cluster.markers) { adapter.add(m.getTitle()); } adapter.notifyDataSetChanged(); // Reconfigure the layout params to position the info window on screen FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) infoWindow.getLayoutParams(); if (orientation == Configuration.ORIENTATION_PORTRAIT) { lp.topMargin = y; lp.leftMargin = defaultMargin; lp.rightMargin = defaultMargin; lp.width = LayoutParams.MATCH_PARENT; lp.height = LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.LEFT | Gravity.TOP; infoWindow.setBackgroundResource(R.drawable.info_window_bg_up); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { lp.leftMargin = x + defaultMargin; lp.topMargin = defaultMargin; lp.bottomMargin = defaultMargin; lp.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; lp.width = LayoutParams.WRAP_CONTENT; lp.height = LayoutParams.WRAP_CONTENT; infoWindow.setBackgroundResource(R.drawable.info_window_bg_left); } infoWindow.setLayoutParams(lp); fullScreenOverlay.setVisibility(View.VISIBLE); }
From source file:com.kubotaku.android.code4kyoto5374.fragments.HomeSelectFragment.java
private void showPlaceSelector(RealmResults<AreaDays> areaDaysResult) { final TextView textAlert = (TextView) getView().findViewById(R.id.text_place_alert); final Spinner spinner = (Spinner) getView().findViewById(R.id.spinner_select_town); if (areaDaysResult.size() <= 1) { textAlert.setVisibility(View.GONE); spinner.setVisibility(View.GONE); if (areaDaysResult.size() == 1) { showValidSelectedAreaDays(areaDaysResult.first()); }/*from w ww . j a v a 2 s .co m*/ } else { textAlert.setVisibility(View.VISIBLE); spinner.setVisibility(View.VISIBLE); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); for (AreaDays areaDays : areaDaysResult) { adapter.add(areaDays.areaName); } spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(onTownSelectedListener); } }
From source file:org.sufficientlysecure.keychain.ui.dialog.CreateKeyDialogFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void replaceArrayAdapterContent(ArrayAdapter<CharSequence> arrayAdapter, int stringArrayResourceId) { final String[] spinnerValuesStringArray = getResources().getStringArray(stringArrayResourceId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { arrayAdapter.addAll(spinnerValuesStringArray); } else {//from w w w. j ava 2s. co m for (final String value : spinnerValuesStringArray) { arrayAdapter.add(value); } } }
From source file:com.bangalore.barcamp.activity.ShareActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.share_screen); mDrawerToggle = BCBFragmentUtils.setupActionBar(this, "Share"); // BCBUtils.createActionBarOnActivity(this); // BCBUtils.addNavigationActions(this); ((EditText) findViewById(R.id.editText1)).addTextChangedListener(new TextWatcher() { @Override//from www . java 2s . c o m public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { ((TextView) findViewById(R.id.charsLeftTextView)).setText("Chars left: " + (140 - s.length() - 7)); } }); if (getIntent().hasExtra(SHARE_STRING)) { ((EditText) findViewById(R.id.editText1)).setText(getIntent().getStringExtra(SHARE_STRING)); } Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); final PackageManager pm = getPackageManager(); final Spinner spinner = (Spinner) findViewById(R.id.shareTypeSpinner); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); String selectedItem = BCBSharedPrefUtils.getShareSettings(getApplicationContext()); int selectedPos = -1; for (ResolveInfo info : matches) { adapter.add(info.loadLabel(pm)); if (selectedItem.equals(info.loadLabel(pm))) { selectedPos = matches.indexOf(info); } } spinner.setAdapter(adapter); if (selectedPos != -1) { spinner.setSelected(true); spinner.setSelection(selectedPos); } ((TextView) findViewById(R.id.charsLeftTextView)).setText("Chars left: 140"); ((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); int appSelectedPos = spinner.getSelectedItemPosition(); ResolveInfo info = matches.get(appSelectedPos); intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); BCBSharedPrefUtils.setShareSettings(getApplicationContext(), (String) info.loadLabel(pm)); intent.putExtra(Intent.EXTRA_TEXT, ((EditText) findViewById(R.id.editText1)).getText().toString() + " #barcampblr"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } }); BCBFragmentUtils.addNavigationActions(this); supportInvalidateOptionsMenu(); Tracker t = ((BarcampBangalore) getApplication()).getTracker(); // Set screen name. t.setScreenName(this.getClass().getName()); // Send a screen view. t.send(new HitBuilders.AppViewBuilder().build()); }
From source file:info.guardianproject.otr.app.im.app.AccountWizardActivity.java
private void addGoogleAccount() { // mNewUser = newUser; AlertDialog.Builder builderSingle = new AlertDialog.Builder(this); // builderSingle.setTitle("Select One Name:-"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_singlechoice); for (Account gAccount : mGoogleAccounts) arrayAdapter.add(gAccount.name); builderSingle.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override/* w w w . jav a 2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mNewUser = arrayAdapter.getItem(which); Thread thread = new Thread() { @Override public void run() { //get the oauth token //don't store anything just make sure it works! String password = GTalkOAuth2.NAME + ':' + GTalkOAuth2.getGoogleAuthTokenAllow(mNewUser, getApplicationContext(), AccountWizardActivity.this, mHandlerGoogleAuth); //use the XMPP type plugin for google accounts, and the .NAME "X-GOOGLE-TOKEN" as the password showSetupAccountForm(helper.getProviderNames().get(0), mNewUser, password, false, getString(R.string.google_account), false); } }; thread.start(); } }); builderSingle.show(); }
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); }// ww w. j a va 2s .com 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:li.klass.fhem.fragments.TimerDetailFragment.java
private void createTimerTypeSpinner(View view) { Spinner typeSpinner = getTypeSpinner(view); ArrayAdapter<String> timerTypeAdapter = new ArrayAdapter<>(getActivity(), R.layout.spinnercontent); for (AtDevice.TimerType type : AtDevice.TimerType.values()) { timerTypeAdapter.add(view.getContext().getString(type.getText())); }/* ww w .j a v a 2s.co m*/ typeSpinner.setAdapter(timerTypeAdapter); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { TimerDetailFragment.this.type = AtDevice.TimerType.values()[i]; } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); }