Check fragment is presented in framelayout or not in android? -
hi friends have 2 framelayout in movies.xml namely container, detail_screen.in container add movies.xml contains listview ,and in detail_screen have expandable listview called movie_details.xml.now want check programatically in detail_screen fragment presented or not.if presented want remove fragment.i did follwing , working fine.
if (getsupportfragmentmanager().findfragmentbytag("myfragment") != null) { getsupportfragmentmanager().begintransaction().remove(getsupportfragmentmanager().findfragmentbytag("myfragment")).commit(); }
but there other way find whether fragment presented or not in frame layout in android programatically .thanks in advance
i founded solution follows.i.e before adding fragments details_screen checking if fragment presented popping , add new fragment.
if (getsupportfragmentmanager().findfragmentbyid(r.id.detail_screen) != null) { getsupportfragmentmanager().popbackstack(); } //to add fragment
hope work.
Comments
Post a Comment