Is there any way that i can get result from two different cursor loader in onCreateLoader in Android -


i trying number , email address phone's contact book. number content uri contactscontract.commomdatakinds.phone.content_uri , email contactscontract.commomdatakinds.email.content_uri want pass these 2 uri cursor loader , result these problem cursor loader can return 1 cursor @ time. can me out solving problem code given below

public class cursor extends fragment implements loadermanager.loadercallbacks<android.database.cursor> {     listview listview;     arraylist<string> contact_id;     int position=0;     private static final int url_loader = 0;      private static final int name_url = 1;     private static final int number_url = 2;     private static final int email_url = 3;      public string[] mfromcolumns = {             contactscontract.commondatakinds.phone._id,             contactscontract.commondatakinds.phone.display_name_primary,             contactscontract.commondatakinds.phone.number,             contactscontract.commondatakinds.email.address       };      public int[] mtofields = {             r.id.text1,             r.id.text2,             r.id.text3,             r.id.text4     };      simplecursoradapter madapter;      @nullable     @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {           view v = inflater.inflate(r.layout.cursor,container,false);           getloadermanager().initloader(number_url, null, this);         getloadermanager().initloader(email_url, null, this);          listview = (listview) v.findviewbyid(r.id.list_item);           madapter =                 new simplecursoradapter(                         getcontext(),                // current context                         r.layout.textview,  // layout single row                         null,                // no cursor yet                         mfromcolumns,        // cursor columns use                         mtofields,           // layout fields use                         0                    // no flags                 );  // sets adapter view         listview.setadapter(madapter);           return v;     }       @override     public loader<android.database.cursor> oncreateloader(int i, bundle bundle) {              switch (i) {                  case number_url:                     log.i("url_loader","loading data");                     // returns new cursorloader                     return new cursorloader(                             getactivity(),   // parent activity context                             contactscontract.commondatakinds.phone.content_uri,// table query                             null,     // projection return                             null,            // no selection clause                             null,            // no selection arguments                             null             // default sort order                     );                 case email_url:                     log.i("url_loader","loading data");                     // returns new cursorloader                     return new cursorloader(                             getactivity(),   // parent activity context                             contactscontract.commondatakinds.email.content_uri,        // table query                             null,     // projection return                             null,            // no selection clause                             null,            // no selection arguments                             null             // default sort order                     );                 default:                     log.i("url_loader","not loading");                     // invalid id passed in                     return null;              }     }      @override     public void onloadfinished(loader<android.database.cursor> loader, android.database.cursor cursor) {            madapter.swapcursor(cursor);       }      @override     public void onloaderreset(loader<android.database.cursor> loader) {         madapter.swapcursor(null);     } } 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -