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
Post a Comment