public class MyListActivity extends ListActivity { private MyCustomListAdapter mAdapter; private ArrayListmData; // onCreate method and other methods omitted for brevity @Override protected void onResume() { super.onResume(); // Check if a new item was added to the list, and update the adapter if necessary if (newItemAdded()) { mData = getUpdatedListData(); mAdapter.setData(mData); mAdapter.notifyDataSetChanged(); } } private boolean newItemAdded() { // Check whether a new item was added to the list // Return true if a new item was added, false otherwise } private ArrayList getUpdatedListData() { // Get the updated list data from your data source } }
public class MyListActivity extends ListActivity { private MyCustomListAdapter mAdapter; private ArrayListIn this example, we are simply refreshing our list data every time the activity is resumed. We get the updated data using the getUpdatedListData() method, update our adapter, and call notifyDataSetChanged() to refresh the list. Package library: android.appmData; // onCreate method and other methods omitted for brevity @Override protected void onResume() { super.onResume(); // Refresh the list data when the activity is resumed mData = getUpdatedListData(); mAdapter.setData(mData); mAdapter.notifyDataSetChanged(); } private ArrayList getUpdatedListData() { // Get the updated list data from your data source } }