Java Code Examples for android.widget.ArrayAdapter#addAll()
The following examples show how to use
android.widget.ArrayAdapter#addAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsyncNavigationAdapter.java From rss with GNU General Public License v3.0 | 7 votes |
@Override protected void onPostExecute(String[][] result) { // Set the titles & counts arrays in this file and notify the adapter. ListView navigationList = (ListView) m_activity.findViewById(R.id.fragment_navigation_drawer); WrapperListAdapter wrapperAdapter = (WrapperListAdapter) navigationList.getAdapter(); ArrayAdapter<String[]> adapter = (ArrayAdapter<String[]>) wrapperAdapter.getWrappedAdapter(); // Update the data in the adapter. adapter.clear(); adapter.addAll(result); // Update the subtitle. if(Constants.s_fragmentFeeds.isVisible()) { Utilities.setTitlesAndDrawerAndPage(null, -10); } }
Example 2
Source File: ActivityEditTransaction.java From fingen with Apache License 2.0 | 6 votes |
private void showAddMarkerDialog() { int selStart = edSms.getSelectionStart(); int selEnd = edSms.getSelectionEnd(); if (selEnd == selStart) { Toast.makeText(ActivityEditTransaction.this, getString(R.string.msg_select_marker_text_before), Toast.LENGTH_SHORT).show(); return; } AlertDialog.Builder builderSingle = new AlertDialog.Builder(this); builderSingle.setTitle(this.getResources().getString(R.string.msg_select_marker_type)); final ArrayAdapter<SmsMarkerManager.SmsMarkerType> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); arrayAdapter.addAll(SmsMarkerManager.getSmsMarkerTypeObjects(transaction.getTransactionType(), this)); builderSingle.setNegativeButton( this.getResources().getString(android.R.string.cancel), (dialog, which) -> dialog.dismiss()); String selectedText = sms.getmBody().subSequence(Math.max(0, Math.min(selStart, selEnd)), Math.max(0, Math.max(selStart, selEnd))).toString(); builderSingle.setAdapter(arrayAdapter, new OnMarkersDialogOkListener(selectedText)); builderSingle.show(); }
Example 3
Source File: PictureResizeDialog.java From Onosendai with Apache License 2.0 | 6 votes |
public PictureResizeDialog (final Context context, final Uri pictureUri) { this.context = context; this.srcMetadata = new ImageMetadata(this.context, pictureUri); final LayoutInflater inflater = LayoutInflater.from(context); this.llParent = inflater.inflate(R.layout.pictureresizedialog, null); this.imgPreview = (ImageView) this.llParent.findViewById(R.id.imgPreview); this.spnScale = (Spinner) this.llParent.findViewById(R.id.spnScale); this.spnQuality = (Spinner) this.llParent.findViewById(R.id.spnQuality); this.prgRedrawing = (ProgressBar) this.llParent.findViewById(R.id.prgRedrawing); this.txtSummary = (TextView) this.llParent.findViewById(R.id.txtSummary); final ArrayAdapter<Scale> scaleAdapter = new ArrayAdapter<Scale>(context, R.layout.numberspinneritem); scaleAdapter.addAll(SCALES); this.spnScale.setAdapter(scaleAdapter); this.spnScale.setSelection(DEFAULT_SCALES_POS); this.spnScale.setOnItemSelectedListener(this.spnChangeListener); final ArrayAdapter<Scale> qualityAdapter = new ArrayAdapter<Scale>(context, R.layout.numberspinneritem); qualityAdapter.addAll(QUALITIES); this.spnQuality.setAdapter(qualityAdapter); this.spnQuality.setSelection(DEFAULT_QUALITY_POS); this.spnQuality.setOnItemSelectedListener(this.spnChangeListener); }
Example 4
Source File: DropdownView.java From Dashchan with Apache License 2.0 | 6 votes |
public void setItems(Collection<? extends CharSequence> collection) { ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_spinner_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); if (C.API_LOLLIPOP && convertView == null) { view.setPadding(0, 0, 0, 0); } return view; } }; adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.addAll(collection); spinner.setAdapter(adapter); }
Example 5
Source File: MainActivity.java From a-sync-browser with Mozilla Public License 2.0 | 6 votes |
private void updateSearchResultListView(){ ListView listView = (ListView) findViewById(R.id.main_search_results_list_view); ArrayAdapter<FileInfo> arrayAdapter=((ArrayAdapter)listView.getAdapter()); arrayAdapter.clear(); if(searchCompletedEvent==null || searchCompletedEvent.hasZeroResults()){ Log.i("Main", "updateSearchResultListView, no result"); ((TextView)findViewById(R.id.main_search_results_empty_element)).setText(R.string.no_search_result_message); }else if(searchCompletedEvent.hasTooManyResults()) { Log.i("Main", "updateSearchResultListView, too many results"); ((TextView)findViewById(R.id.main_search_results_empty_element)).setText(R.string.too_many_search_results_message); }else{ List<FileInfo> list = searchCompletedEvent.getResultList(); Log.i("Main", "updateSearchResultListView, result count = " + list.size()); arrayAdapter.addAll(list); } arrayAdapter.notifyDataSetChanged(); listView.setSelection(0); }
Example 6
Source File: DialogCreator.java From no-player with Apache License 2.0 | 6 votes |
void showSubtitleSelectionDialog() { final List<PlayerSubtitleTrack> subtitleTracks = noPlayer.getSubtitleTracks(); ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.list_item); adapter.addAll(mapSubtitleTrackToLabel(subtitleTracks)); new AlertDialog.Builder(context) .setTitle("Select subtitle track") .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int position) { if (position == AUTO_TRACK_POSITION) { noPlayer.hideSubtitleTrack(); } else { PlayerSubtitleTrack subtitleTrack = subtitleTracks.get(position - 1); noPlayer.showSubtitleTrack(subtitleTrack); } } }) .create() .show(); }
Example 7
Source File: DialogCreator.java From no-player with Apache License 2.0 | 6 votes |
void showAudioSelectionDialog() { final AudioTracks audioTracks = noPlayer.getAudioTracks(); ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.list_item); adapter.addAll(mapAudioTrackToLabel(audioTracks)); new AlertDialog.Builder(context) .setTitle("Select audio track") .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int position) { if (position == AUTO_TRACK_POSITION) { noPlayer.clearAudioTrackSelection(); } else { PlayerAudioTrack audioTrack = audioTracks.get(position - 1); noPlayer.selectAudioTrack(audioTrack); } } }) .create() .show(); }
Example 8
Source File: DialogCreator.java From no-player with Apache License 2.0 | 6 votes |
void showVideoSelectionDialog() { final List<PlayerVideoTrack> videoTracks = noPlayer.getVideoTracks(); ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.list_item); adapter.addAll(mapVideoTrackToLabel(videoTracks)); new AlertDialog.Builder(context) .setTitle("Select Video track") .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int position) { if (position == AUTO_TRACK_POSITION) { noPlayer.clearVideoTrackSelection(); } else { PlayerVideoTrack videoTrack = videoTracks.get(position - 1); noPlayer.selectVideoTrack(videoTrack); } } }) .create() .show(); }
Example 9
Source File: UtilsListFragment.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayAdapter<String> adapter = new ArrayAdapter<String>( getActivity(), android.R.layout.simple_list_item_1 ); String[] items = getResources().getStringArray( R.array.list_items ); adapter.addAll( new ArrayList( Arrays.asList(items) ) ); setListAdapter( adapter ); }
Example 10
Source File: Adapters.java From Android-Commons with Apache License 2.0 | 5 votes |
/** * Adds all the items from the specified collection to the given adapter at once * * @param adapter the adapter to insert the items into * @param items the items to insert */ @SuppressLint("NewApi") public static <T> void addAll(final ArrayAdapter<T> adapter, final Collection<T> items) { if (Build.VERSION.SDK_INT >= 11) { adapter.addAll(items); } else { for (T item : items) { adapter.add(item); } } }
Example 11
Source File: ExportActivity.java From PocketMaps with MIT License | 5 votes |
private void fillSpinner() { ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line); adapter.addAll(IO.listSelectionPaths(this, false)); exSpinner.setAdapter(adapter); exSpinner.setOnItemSelectedListener(this); }
Example 12
Source File: MyListFragment.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void setListContent(List<RssItem> result) { list = result; ArrayAdapter listAdapter = (ArrayAdapter) getListAdapter(); listAdapter.clear(); listAdapter.addAll(result); parseTask.setFragment(null); parseTask = null; }
Example 13
Source File: RssfeedListFragment.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") public void setListContent(List<RssItem> result) { ArrayAdapter<RssItem> listAdapter = (ArrayAdapter<RssItem>) getListAdapter(); listAdapter.clear(); listAdapter.addAll(result); parseTask.setFragment(null); parseTask = null; }
Example 14
Source File: TextFiltersDialog.java From Onosendai with Apache License 2.0 | 5 votes |
public TextFiltersDialog (final Context context, final String inputText) { this.context = context; this.inputText = inputText; final LayoutInflater inflater = LayoutInflater.from(context); this.llParent = inflater.inflate(R.layout.textfilters, null); this.txtPreview = ((TextView) this.llParent.findViewById(R.id.txtPreview)); this.spnFilters = ((Spinner) this.llParent.findViewById(R.id.spnFilters)); final ArrayAdapter<TextFilter> filtersAdapter = new ArrayAdapter<TextFilter>(context, R.layout.numberspinneritem); filtersAdapter.addAll(TextFilter.values()); this.spnFilters.setAdapter(filtersAdapter); this.spnFilters.setOnItemSelectedListener(this.spnChangeListener); }
Example 15
Source File: ContentFragment.java From android-sliderview with MIT License | 5 votes |
private View setUpList(View view) { ListView listView = (ListView) view; ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1); listView.setOnScrollListener((ExampleActivity) getActivity()); adapter.addAll( "one two three four five six seven eight nine one two three four five six seven eight nine one two three four five six seven eight nine".split(" ") ); listView.setAdapter(adapter); return listView; }
Example 16
Source File: AsyncManageAdapter.java From rss with GNU General Public License v3.0 | 5 votes |
@Override protected void onProgressUpdate(String[][]... values) { // Creating a new adapter seems to fix items not updating. ArrayAdapter<String[]> adapterManage = new AdapterManageItems(m_activity); m_listFragment.setListAdapter(adapterManage); adapterManage.addAll(values[0]); }
Example 17
Source File: MyListFragment.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void setListContent(List<RssItem> result) { ArrayAdapter listAdapter = (ArrayAdapter) getListAdapter(); listAdapter.clear(); listAdapter.addAll(result); parseTask.setFragment(null); parseTask = null; }
Example 18
Source File: MainActivity.java From a-sync-browser with Mozilla Public License 2.0 | 4 votes |
private void navigateToFolder(FileInfo fileInfo) { Log.d("navigateToFolder", "BEGIN"); if (indexBrowser.isRoot() && PathUtils.isParent(fileInfo.getPath())) { showAllFoldersListView(); //navigate back to folder list } else { if (fileInfo.isDirectory()) { indexBrowser.navigateTo(fileInfo); FileInfo newFileInfo=PathUtils.isParent(fileInfo.getPath())?indexBrowser.getCurrentPathInfo():fileInfo; if (!indexBrowser.isCacheReadyAfterALittleWait()) { Log.d("navigateToFolder", "load folder cache bg"); new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { updateMainProgressBar(true,"open directory: " + (indexBrowser.isRoot() ? folderBrowser.getFolderInfo(indexBrowser.getFolder()).getLabel() : indexBrowser.getCurrentPathFileName())); } @Override protected Void doInBackground(Void... voids) { indexBrowser.waitForCacheReady(); return null; } @Override protected void onPostExecute(Void aVoid) { Log.d("navigateToFolder", "cache ready, navigate to folder"); updateMainProgressBar(false,null); navigateToFolder(newFileInfo); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { List<FileInfo> list = indexBrowser.listFiles(); Log.i("navigateToFolder", "list for path = '" + indexBrowser.getCurrentPath() + "' list = " + list.size() + " records"); Log.d("navigateToFolder", "list for path = '" + indexBrowser.getCurrentPath() + "' list = " + list); checkArgument(!list.isEmpty());//list must contain at least the 'parent' path ListView listView = (ListView) findViewById(R.id.main_folder_and_files_list_view); ArrayAdapter adapter = (ArrayAdapter) listView.getAdapter(); adapter.clear(); adapter.addAll(list); adapter.notifyDataSetChanged(); listView.setSelection(0); saveCurrentFolder(); ((TextView) findViewById(R.id.main_header_folder_label)).setText(indexBrowser.isRoot() ?folderBrowser.getFolderInfo(indexBrowser.getFolder()).getLabel() :newFileInfo.getFileName()); } } else { pullFile(fileInfo); } } Log.d("navigateToFolder", "END"); }
Example 19
Source File: Api11Adapter.java From mytracks with Apache License 2.0 | 4 votes |
@Override public <T> void addAllToArrayAdapter(ArrayAdapter<T> arrayAdapter, List<T> items) { arrayAdapter.addAll(items); }
Example 20
Source File: AlarmUtils.java From PrayTime-Android with Apache License 2.0 | 4 votes |
public static void getRingtonesDialog(Activity activity, Collection<String> items, int selected, DialogInterface.OnClickListener itemClickListener, DialogInterface.OnClickListener okClickListener, final DialogInterface.OnClickListener cancelClickListener) { AlertDialog.Builder builderSingle = new AlertDialog.Builder(activity); builderSingle.setTitle("Select Ringtone"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, android.R.layout.select_dialog_singlechoice); arrayAdapter.addAll(items); builderSingle.setNegativeButton(android.R.string.cancel, cancelClickListener); builderSingle.setPositiveButton(android.R.string.ok, okClickListener); builderSingle.setSingleChoiceItems(arrayAdapter, selected, itemClickListener); builderSingle.setCancelable(false); builderSingle.show(); }