android - Show/Hide two fragments in a single Layout [Both fragments have a Google map each] -
i have activity relative layout; , have 2 different fragments. show 1 fragment , switch next fragment on button click vice verse.
// when button menu clicked onclicklistener btnclick = new onclicklistener() { @override public void onclick(view arg0) { if(currenttype==0){ initthisfragment(1); }else{ initthisfragment(0); } } }; public void initthisfragment(int type){ fragment newfragment; if(type==0){ newfragment=new mainfragment(); }else{ newfragment=new journeyfragment(); } currenttype=type; fragmenttransaction transaction = getsupportfragmentmanager().begintransaction(); transaction.replace(r.id.abs_fragment_container, newfragment); transaction.addtobackstack(null); transaction.commit(); }
r.id.abs_fragment_container relative layout
both fragment contain google maps inside them;
but not working expected.
- by default add first fragment [which works fine].
- then after onclick event 2nd fragment comes[which works fine]
- but on next click app crashes;
please new google maps , fragments;
yeah of course app crashes because fragment map exists @ thread helped me lot: duplicate id, tag null, or parent id fragment com.google.android.gms.maps.mapfragment
especially second answer 41 ups easy understand
and yes have posted 1 in comment if have enough reputation it!
Comments
Post a Comment