android - Correct way to remove all (Child) fragments -
i load bunch of child fragments dynamically inside parent's fragment linearlayout (fragmentcontainer), when user clicks button, need remove them , add new ones. don't know exact number of fragments added each time. way of removing fragments @ once
linearlayout ll = (linearlayout) view.findviewbyid(r.id.fragmentcontainer); ll.removeallviews();
now can add new ones using fragment transaction methods. way of removing fragments super easy , works me better removing each fragment 1 one using remove() practice? how performance? recommend better way?
this way of removing fragments @ once
no, isn't. way of removing views container.
this way of removing fragments super easy , works me.
it remove fragments. removes views. why method named removeallviews()
.
but practice?
no. starters, when rotate device or undergo configuration change, notice "removed" fragments come back.
do recommend better way?
keep track of outstanding fragments (e.g., using arraylist<fragment>
), iterate on list, passing each remove()
method on fragmenttransaction
.
Comments
Post a Comment