List of usage examples for android.widget ArrayAdapter add
public void add(@Nullable T object)
From source file:br.com.bioscada.apps.biotracks.util.AccountUtils.java
/** * Sets up account spinner.// w w w .ja va2 s .com * * @param fragmentActivity tyhe fragment activity * @param spinner the spinner * @param accounts the accounts */ public static void setupAccountSpinner(FragmentActivity fragmentActivity, Spinner spinner, Account[] accounts) { if (accounts.length > 1) { String shareTrackAccount = PreferencesUtils.getString(fragmentActivity, R.string.share_track_account_key, PreferencesUtils.SHARE_TRACK_ACCOUNT_DEFAULT); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(fragmentActivity, R.layout.account_spinner_item); int selection = 0; for (int i = 0; i < accounts.length; i++) { String name = accounts[i].name; adapter.add(name); if (name.equals(shareTrackAccount)) { selection = i; } } adapter.setDropDownViewResource(R.layout.account_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(selection); } }
From source file:com.nextgis.mobile.map.RemoteTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, String layerUrl, int type, final RemoteTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);/*from ww w. j a v a2 s .co m*/ final EditText url = new EditText(map.getContext()); url.setText(layerUrl); final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerUrl = new TextView(map.getContext()); stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(0); } else { spinner.setSelection(1); } linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerUrl); linearLayout.addView(url); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), url.getText().toString(), tmsType); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:com.nextgis.mobile.map.LocalTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, int type, final Uri uri, final LocalTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);//from www . j ava2 s . com final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_qtiles)); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(1); } else { spinner.setSelection(2); } final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), tmsType, uri); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:im.vector.activity.CommonActivityUtils.java
/** * Offer to send some dedicated intent data to an existing room * @param fromActivity the caller activity * @param intent the intent param//ww w . jav a 2 s. c om * @param session the session/ */ public static void sendFilesTo(final Activity fromActivity, final Intent intent, final MXSession session) { // sanity check if ((null == session) || !session.isActive()) { return; } final ArrayList<RoomSummary> mergedSummaries = new ArrayList<RoomSummary>(); mergedSummaries.addAll(session.getDataHandler().getStore().getSummaries()); Collections.sort(mergedSummaries, new Comparator<RoomSummary>() { @Override public int compare(RoomSummary lhs, RoomSummary rhs) { if (lhs == null || lhs.getLatestEvent() == null) { return 1; } else if (rhs == null || rhs.getLatestEvent() == null) { return -1; } if (lhs.getLatestEvent().getOriginServerTs() > rhs.getLatestEvent().getOriginServerTs()) { return -1; } else if (lhs.getLatestEvent().getOriginServerTs() < rhs.getLatestEvent().getOriginServerTs()) { return 1; } return 0; } }); AlertDialog.Builder builderSingle = new AlertDialog.Builder(fromActivity); builderSingle.setTitle(fromActivity.getText(R.string.send_files_in)); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(fromActivity, R.layout.dialog_room_selection); for (RoomSummary summary : mergedSummaries) { arrayAdapter.add(summary.getRoomName()); } builderSingle.setNegativeButton(fromActivity.getText(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, final int which) { dialog.dismiss(); fromActivity.runOnUiThread(new Runnable() { @Override public void run() { RoomSummary summary = mergedSummaries.get(which); CommonActivityUtils.goToRoomPage(session, summary.getRoomId(), fromActivity, intent); } }); } }); builderSingle.show(); }
From source file:com.google.android.apps.mytracks.util.Api8Adapter.java
@Override public <T> void addAllToArrayAdapter(ArrayAdapter<T> arrayAdapter, List<T> items) { for (T item : items) { arrayAdapter.add(item); }// w ww . j a v a2 s . co m }
From source file:com.appdynamics.demo.gasp.fragment.ReviewDetailsFragment.java
public void showReviewDetails(List<Review> reviews) { // Use a simple TextView layout for ArrayAdapter constructor ArrayAdapter<String> mReviewAdapter = new ArrayAdapter<String>(getActivity(), R.layout.gasp_generic_textview, new ArrayList<String>()); setListAdapter(mReviewAdapter);//from w w w . jav a2 s. c o m for (Review review : reviews) { mReviewAdapter.add(review.toString()); } }
From source file:com.appdynamics.demo.gasp.fragment.TwitterResponderFragment.java
private void setTweets() { TwitterStreamActivity activity = (TwitterStreamActivity) getActivity(); try {//from w w w .j a v a 2 s . co m // Get Twitter search keyword from Shared Preferences SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String keyword = gaspSharedPreferences.getString(getString(R.string.gasp_twitter_preferences), ""); if (mTweets == null) { Intent intent = new Intent(activity, RESTIntentService.class); intent.setData(Uri.parse(TwitterAPI.getTwitterApiSearch())); Bundle params = new Bundle(); params.putString("q", keyword); params.putString("count", "10"); Bundle headers = new Bundle(); headers.putString("Authorization", "Bearer " + TwitterStreamActivity.getTwitterOAuthToken()); intent.putExtra(RESTIntentService.EXTRA_PARAMS, params); intent.putExtra(RESTIntentService.EXTRA_HEADERS, headers); intent.putExtra(RESTIntentService.EXTRA_RESULT_RECEIVER, getResultReceiver()); activity.startService(intent); } else if (activity != null) { ArrayAdapter<String> adapter = activity.getArrayAdapter(); adapter.clear(); for (String tweet : mTweets) { adapter.add(tweet); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.cloudbees.gasp.fragment.TwitterResponderFragment.java
private void setTweets() { TwitterStreamActivity activity = (TwitterStreamActivity) getActivity(); try {//from w w w . ja va2 s . c o m // Get Twitter search keyword from Shared Preferences SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); String keyword = gaspSharedPreferences.getString(getString(R.string.gasp_twitter_preferences), ""); if (mTweets == null && activity != null) { Intent intent = new Intent(activity, RESTIntentService.class); intent.setData(Uri.parse(TwitterAPI.getTwitterApiSearch())); Bundle params = new Bundle(); params.putString("q", keyword); params.putString("count", "10"); Bundle headers = new Bundle(); headers.putString("Authorization", "Bearer " + TwitterStreamActivity.getTwitterOAuthToken()); intent.putExtra(RESTIntentService.EXTRA_PARAMS, params); intent.putExtra(RESTIntentService.EXTRA_HEADERS, headers); intent.putExtra(RESTIntentService.EXTRA_RESULT_RECEIVER, getResultReceiver()); activity.startService(intent); } else if (activity != null) { ArrayAdapter<String> adapter = activity.getArrayAdapter(); adapter.clear(); for (String tweet : mTweets) { adapter.add(tweet); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.cloudbees.gasp.fragment.TwitterSearchResponderFragment.java
private void setTweets() { TwitterRESTServiceActivity activity = (TwitterRESTServiceActivity) getActivity(); if (mTweets == null && activity != null) { // This is where we make our REST call to the service. We also pass in our ResultReceiver // defined in the RESTResponderFragment super class. // We will explicitly call our Service since we probably want to keep it as a private // component in our app. You could do this with Intent actions as well, but you have // to make sure you define your intent filters correctly in your manifest. Intent intent = new Intent(activity, RESTService.class); intent.setData(Uri.parse("http://search.twitter.com/search.json")); // Here we are going to place our REST call parameters. Note that // we could have just used Uri.Builder and appendQueryParameter() // here, but I wanted to illustrate how to use the Bundle params. Bundle params = new Bundle(); params.putString("q", "cloudbees"); intent.putExtra(RESTService.EXTRA_PARAMS, params); intent.putExtra(RESTService.EXTRA_RESULT_RECEIVER, getResultReceiver()); // Here we send our Intent to our RESTService. activity.startService(intent);/*w w w .ja v a 2 s .c o m*/ } else if (activity != null) { // Here we check to see if our activity is null or not. // We only want to update our views if our activity exists. ArrayAdapter<String> adapter = activity.getArrayAdapter(); // Load our list adapter with our Tweets. adapter.clear(); for (String tweet : mTweets) { adapter.add(tweet); } } }
From source file:edward.com.example.AnimationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animation); Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar);// w w w . j a va 2 s . co m getSupportActionBar().setDisplayShowTitleEnabled(false); setViewPagerEffect(new Tablet()); Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); for (PagerType type : PagerType.values()) { spinnerAdapter.add(type.name()); } spinner.setAdapter(spinnerAdapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setEffecft(PagerType.values()[position].name()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }