android - Starting activity inside fragment boundaries itself -
i want start new activity inside fragment boundaries instead of loading in complete new full screen.
i tried :
fragmentmanager fragmentmanager = getfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction(); intent intent = new intent(this,menufragmentactivity.class); menufragment newfragment = new menufragment(); fragmenttransaction.add(r.id.menufragment,newfragment); newfragment.startactivity(intent); fragmenttransaction.commit();
but starts activity in new screen rather in confined fragment ?
the behavior you're seeing correct.
for layout purposes, activities cannot "children" of fragments. it's other way around: fragments children of activities. so, basically, you're trying won't work.
you should read full fragments guide if haven't already. here's relevant quote layouts:
when add fragment part of activity layout, lives in viewgroup inside activity's view hierarchy , fragment defines own view layout. can insert fragment activity layout declaring fragment in activity's layout file,
<fragment>
element, or application code adding existing viewgroup.
instead of starting new activity, try loading fragment within original fragment's layout.
Comments
Post a Comment