Java Code Examples for android.widget.ArrayAdapter#clear()
The following examples show how to use
android.widget.ArrayAdapter#clear() .
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: 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 3
Source File: FloatingToolbar.java From Telegram with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") private void layoutOverflowPanelItems(List<MenuItem> menuItems) { ArrayAdapter<MenuItem> overflowPanelAdapter = (ArrayAdapter<MenuItem>) mOverflowPanel.getAdapter(); overflowPanelAdapter.clear(); final int size = menuItems.size(); for (int i = 0; i < size; i++) { overflowPanelAdapter.add(menuItems.get(i)); } mOverflowPanel.setAdapter(overflowPanelAdapter); if (mOpenOverflowUpwards) { mOverflowPanel.setY(0); } else { mOverflowPanel.setY(mOverflowButtonSize.getHeight()); } int width = Math.max(getOverflowWidth(), mOverflowButtonSize.getWidth()); int height = calculateOverflowHeight(MAX_OVERFLOW_SIZE); mOverflowPanelSize = new Size(width, height); setSize(mOverflowPanel, mOverflowPanelSize); }
Example 4
Source File: InfiniteScrollUtils.java From edx-app-android with Apache License 2.0 | 6 votes |
@NonNull public static <T> ListContentController<T> configureListContentController(@NonNull ListView list, @NonNull final ArrayAdapter<T> adapter) { final View footerView = LayoutInflater.from(list.getContext()).inflate(R.layout.list_view_footer_progress, list, false); list.addFooterView(footerView, null, false); final View loadingIndicator = footerView.findViewById(R.id.loading_indicator); list.setAdapter(adapter); return new ListContentController<T>() { @Override public void clear() { adapter.clear(); } @Override public void addAll(List<T> items) { adapter.addAll(items); } @Override public void setProgressVisible(boolean visible) { loadingIndicator.setVisibility(visible ? View.VISIBLE : View.GONE); } }; }
Example 5
Source File: FloatingToolbar.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") private void layoutOverflowPanelItems(List<MenuItem> menuItems) { ArrayAdapter<MenuItem> overflowPanelAdapter = (ArrayAdapter<MenuItem>) mOverflowPanel.getAdapter(); overflowPanelAdapter.clear(); final int size = menuItems.size(); for (int i = 0; i < size; i++) { overflowPanelAdapter.add(menuItems.get(i)); } mOverflowPanel.setAdapter(overflowPanelAdapter); if (mOpenOverflowUpwards) { mOverflowPanel.setY(0); } else { mOverflowPanel.setY(mOverflowButtonSize.getHeight()); } int width = Math.max(getOverflowWidth(), mOverflowButtonSize.getWidth()); int height = calculateOverflowHeight(MAX_OVERFLOW_SIZE); mOverflowPanelSize = new Size(width, height); setSize(mOverflowPanel, mOverflowPanelSize); }
Example 6
Source File: ConfigActivity.java From Field-Book with GNU General Public License v2.0 | 6 votes |
private void updateSetupList() { ArrayAdapter<String> ga = (ArrayAdapter) profileList.getAdapter(); if (ga != null) { ga.clear(); } String[] arrayData = prepareSetup(); if (arrayData != null) { for (String string : arrayData) { ga.insert(string, ga.getCount()); } } ga.notifyDataSetChanged(); }
Example 7
Source File: FloatingToolbar.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private void clearPanels() { mOverflowPanelSize = null; mMainPanelSize = null; mIsOverflowOpen = false; mMainPanel.removeAllViews(); ArrayAdapter<MenuItem> overflowPanelAdapter = (ArrayAdapter<MenuItem>) mOverflowPanel.getAdapter(); overflowPanelAdapter.clear(); mOverflowPanel.setAdapter(overflowPanelAdapter); mContentContainer.removeAllViews(); }
Example 8
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 9
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 10
Source File: FloatingToolbar.java From Telegram with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private void clearPanels() { mOverflowPanelSize = null; mMainPanelSize = null; mIsOverflowOpen = false; mMainPanel.removeAllViews(); ArrayAdapter<MenuItem> overflowPanelAdapter = (ArrayAdapter<MenuItem>) mOverflowPanel.getAdapter(); overflowPanelAdapter.clear(); mOverflowPanel.setAdapter(overflowPanelAdapter); mContentContainer.removeAllViews(); }
Example 11
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 12
Source File: AutoCompleteListViewTest.java From open with GNU General Public License v3.0 | 5 votes |
@Test public void setAdapter_shouldHideEmptyViewWhenItemIsRemovedIfListViewHidden() throws Exception { ArrayAdapter adapter = new ArrayAdapter(ACTIVITY, 0); adapter.add(new Object()); View empty = new View(ACTIVITY); autoCompleteListView.setEmptyView(empty); autoCompleteListView.setAdapter(adapter); autoCompleteListView.setVisibility(View.GONE); adapter.clear(); assertThat(empty).isGone(); }
Example 13
Source File: AutoCompleteListViewTest.java From open with GNU General Public License v3.0 | 5 votes |
@Test public void setAdapter_shouldShowEmptyViewWhenItemIsRemovedFromAdapter() throws Exception { ArrayAdapter adapter = new ArrayAdapter(ACTIVITY, 0); adapter.add(new Object()); View empty = new View(ACTIVITY); autoCompleteListView.setEmptyView(empty); autoCompleteListView.setAdapter(adapter); autoCompleteListView.setVisibility(View.VISIBLE); adapter.clear(); assertThat(empty).isVisible(); }
Example 14
Source File: SwipeRefreshListFragmentFragment.java From android-SwipeRefreshListFragment with Apache License 2.0 | 5 votes |
/** * When the AsyncTask finishes, it calls onRefreshComplete(), which updates the data in the * ListAdapter and turns off the progress bar. */ private void onRefreshComplete(List<String> result) { Log.i(LOG_TAG, "onRefreshComplete"); // Remove all items from the ListAdapter, and then replace them with the new items ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter(); adapter.clear(); for (String cheese : result) { adapter.add(cheese); } // Stop the refreshing indicator setRefreshing(false); }
Example 15
Source File: MainActivity.java From azure-notificationhubs-android with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void refreshTestGroupsAndLog() { mLog = new StringBuilder(); ArrayAdapter<TestGroup> adapter = (ArrayAdapter<TestGroup>) mTestGroupSpinner.getAdapter(); adapter.clear(); adapter.add(new MiscTests()); mTestGroupSpinner.setSelection(0); selectTestGroup(0); }
Example 16
Source File: MainActivity.java From Outlook-SDK-Android with MIT License | 5 votes |
@SuppressWarnings("unchecked") private void refreshTestGroupsAndLog() { mLog = new StringBuilder(); Map<String, Map<String, String>> exclusions = GetExclusions(getResources().openRawResource(R.raw.excluded_tests)); ArrayAdapter<TestGroup> adapter = (ArrayAdapter<TestGroup>) mTestGroupSpinner.getAdapter(); adapter.clear(); adapter.add(new ExchangeTests()); mTestGroupSpinner.setSelection(0); selectTestGroup(0); }
Example 17
Source File: KeyAssignmentUtils.java From talkback with Apache License 2.0 | 5 votes |
/** * Updates the arrayadapter to reflect changes in the list of keys assigned. * * @param keyListAdapter The ArrayAdapter to be updated * @param keyCombos The present set of assigned keys * @param context The context of the activity the call came from */ public static void updateKeyListAdapter( ArrayAdapter<CharSequence> keyListAdapter, Set<Long> keyCombos, Context context) { keyListAdapter.clear(); for (long keyCombo : keyCombos) { keyListAdapter.add(KeyAssignmentUtils.describeExtendedKeyCode(keyCombo, context)); } /* Sort the list so the keys appear in a consistent place */ keyListAdapter.sort( (charSequence0, charSequence1) -> charSequence0.toString().compareToIgnoreCase(charSequence1.toString())); }
Example 18
Source File: ConnectionFragment.java From octoandroid with GNU General Public License v3.0 | 5 votes |
private <T> ArrayAdapter<T> updateAdapter(ArrayAdapter<T> adapter, List<T> list) { if (adapter == null) { int spinnerLayoutId = android.R.layout.simple_spinner_dropdown_item; adapter = new ArrayAdapter<>(getContext(), spinnerLayoutId, list); } else { adapter.clear(); adapter.addAll(list); } return adapter; }
Example 19
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 20
Source File: Adapters.java From Android-Commons with Apache License 2.0 | 3 votes |
/** * Sets the items of the given adapter to the specified collection * * This operation includes removing the old items (if any) and adding the new ones * * Any listeners will only be informed about the final result * * @param adapter the adapter for which to set the items * @param content the collection that has the new items */ public static <T> void setItems(final ArrayAdapter<T> adapter, final Collection<T> content) { adapter.setNotifyOnChange(false); adapter.clear(); addAll(adapter, content); adapter.notifyDataSetChanged(); }