android - Why does the fragment manager return null here? -


why log-line yield "true" here? added fragment tag "id"!

fragmenttransaction ftrans = getsupportfragmentmanager().begintransaction(); ftrans.add(0, new myfrag(), "id"); ftrans.commit(); fragment frag =  getsupportfragmentmanager().findfragmentbytag("id"); log.i("", "fragment null? " + (frag == null)); 

is there delay on commit? if so, there event can listen when commit completed?

public abstract int commit ()

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

you can try adding fragmentmanager.executependingtransactions() after commit() , before finding tag.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -