android - Replace fragment in host activity from fragment -
i have container activity has framelayout storing fragment inside it. example have activity initial framgent login page. theare 2 buttons login , register. user can click register , in case need change current fragment fragment registration fields. have idea make host activity implement callback interface , pass activity fragment, , when user clicks register callback method called , host activity replacing fragment. question if there other better way this, maybe more correclty. please leave suggestions , how deal problem.thanks you can replace fragments follows , fragmenttransaction transaction = getfragmentmanager().begintransaction(); transaction.replace(<container id>, new registerfragment()); transaction.commit(); //if using support library, make sure use getsupportfragmentmanager()