Java Code Examples for android.widget.ArrayAdapter#setNotifyOnChange()
The following examples show how to use
android.widget.ArrayAdapter#setNotifyOnChange() .
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: ChatView.java From mortar with Apache License 2.0 | 6 votes |
public ArrayAdapter<Message> getItems() { @SuppressWarnings("unchecked") ArrayAdapter<Message> adapter = (ArrayAdapter<Message>) getAdapter(); if (adapter == null) { adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1); setAdapter(adapter); adapter.setNotifyOnChange(true); setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { presenter.onConversationSelected(position); } }); } return adapter; }
Example 2
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(); }