Here is example with use of LoadManager http://developer.android.com/reference/android/app/LoaderManager.html
example of sectioned adapter is
private class SectionAdapter extends SectionedAdapter {
@Override
protected View getHeaderView(String caption, int index,
View convertView, ViewGroup parent) {
TextView tv = new TextView(LazySectionListActivity.this);
tv.setText(caption);
return tv;
}
}
My problem with LoadManager is that I can not fetch date from separate cursors :(, namely I need to fill the listview with data from two separate cursors and they should be separated in the listview with some header (just like with the sectioned adapter)
how can I display data from separate cursors in the same listview with use of LoadManager
so far I managed to make workable example with only one cursor in the onCreateLoader method
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
Uri baseUri;
baseUri = Contacts.CONTENT_URI;
String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
+ Contacts.HAS_PHONE_NUMBER + "=1) AND ("
+ Contacts.DISPLAY_NAME + " != '' ))";
return new CursorLoader(getActivity(), baseUri,
CONTACTS_SUMMARY_PROJECTION, select, null,
Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
But I need to display data from two separate cursors
I know that I can not have two return statements , but I am trying to illustrate the problem that I do not know how to solve it
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
Uri baseUri;
baseUri = Contacts.CONTENT_URI;
String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
+ Contacts.HAS_PHONE_NUMBER + "=1) AND ("
+ Contacts.DISPLAY_NAME + " != '' ))";
return new CursorLoader(getActivity(), baseUri,
CONTACTS_SUMMARY_PROJECTION, select, null,
Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
//beside the first cursor data that I want to be displayed
//I also want the date from the second cursor
Uri baseUri2;
baseUri = "some other uri";
String select2 = "some other select";
return new CursorLoader(getActivity(), baseUri2,
projection, select2, null,
MyClass.BlaBla + " COLLATE LOCALIZED ASC");
}