android - Does onCreate() called after commit()? -


  private class draweritemclicklistener implements listview.onitemclicklistener {         @override        public void onitemclick(adapterview<?> parent, view view, int position, long id) {            selectitem(position);         }    } 

private void selectitem(int position) {         fragment fragment = new planetfragment();         bundle args = new bundle();         args.putint(planetfragment.arg_planet_number, position);          fragment.setarguments(args);          fragmentmanager fragmentmanager = getfragmentmanager();         fragmentmanager.begintransaction().replace(r.id.content_frame, fragment).commit();          mdrawerlist.setitemchecked(position, true);         settitle(mplanettitles[position]);          mdrawertitle=mplanettitles[position];         mdrawerlayout.closedrawers();       } 

my app demo drawer.the 8 planet drawernavigation demo.when click item of listview shows on drawer,the planet picture on fragment changes.

here confusion:

i think oncreate , oncreateview method of fragment called subsequence "fragmentmanager.begintransaction().replace(r.id.content_frame, fragment).commit();".

but actually,they called after onitemclick() finished. why? in advance.

if read documentation of commit method says:

schedules commit of transaction. commit not happen immediately; scheduled work on main thread done next time thread ready.

since selectitem on main thread, commit won't happen until after selectitem returns (but not right after!).


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 -