Android Fragment - move from one View to another? -


can first add fragment view, "detach" it, , "re-attach" view?

in code, want to:

fragone 1 = new fragone(); getsupportfragmentmanager().begintransaction()         .add(r.id.left, one, "tag").commit();  getsupportfragmentmanager().begintransaction()         .detach(one).commit();      // or .remove(), or .addtobackstack(null).remove()  getsupportfragmentmanager().executependingtransactions();  getsupportfragmentmanager().begintransaction()         .add(r.id.right, one).commit(); 

but throws error:

04-05 13:28:03.492: e/androidruntime(7195): java.lang.runtimeexception: unable start activity componentinfo{com.example.trybackstack/com.example.trybackstack.mainactivity}: java.lang.illegalstateexception: can't change container id of fragment fragone{40523130 #0 id=0x7f080000 tag}: 2131230720 2131230721 

thanks help!

i had same problem found needed reparent fragment's view , not fragment itself, avoiding fragmentmanager transaction.

view vv = fragment.getview(); viewgroup parent = (viewgroup)vv.getparent(); parent.removeview(vv); newparent.addview(vv, layoutparams); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -