I have a simple contentProvider, a layout with a ListView, and a button for adding items to the Content Provider and CursorLoader. http://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks.html#onLoadFinished(android.content.Loader , D) the link indicates that
The bootloader will monitor data changes and notify you through new calls here. You do not have to control the data yourself. For example, if the data is a cursor and you place it in the CursorAdapter, use the CursorAdapter (android.content.Context, android.database.Cursor, int) without passing to FLAG_AUTO_REQUERY or FLAG_REGISTER_CONTENT_OBSERVER (i.e. use 0 for the flags argument). This prevents the CursorAdapter from executing its own Cursor observation, which is not required, since a change will occur, you will get a new Cursor that will cause another call.
But the Log.info line in the onLoadFinished method was not executed, and the listView was not updated. Here is my (simple) code:
public class HomeActivity extends FragmentActivity implements LoaderManager.LoaderCallbacks<Cursor>{ static final String TAG = "HomeActivity"; SimpleCursorAdapter adapter; ListView listAnnunciVicini; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home); listAnnunciVicini = (ListView) findViewById(R.id.lista_annunci_vicini); adapter = new SimpleCursorAdapter(this, R.layout.list_item, null, new String[] { ContentDescriptor.Annunci.Cols.ID, ContentDescriptor.Annunci.Cols.TITOLO, ContentDescriptor.Annunci.Cols.DESCRIZIONE }, new int[] { R.id.list_annunci_item_id_annuncio, R.id.list_annunci_item_titolo_annuncio, R.id.list_annunci_item_descrizione_annuncio }, 0); listAnnunciVicini.setAdapter(adapter);
Any suggestion?
ilcaduceo
source share