Reputation: 772
i have trouble with attaching two fragments in one layout. I know how to add one fragment in a layout but I don't know how to put two fragments next to each other vertically in java android. here adding one fragment is fully explained but there is no tutorial for putting two or more fragments in one layout.
Upvotes: 0
Views: 1538
Reputation: 10338
You can try something like this:
FragmentTransaction ft = getFragmentManager()
.beginTransaction();
Fragment fragment = new MyAwsomeFragment();
ft.add(R.id.linearLayoutActivity, fragment, null);//dont add to backstack
ft.commit();
Here R.id.linearLayoutActivity points to a layout currently visible and inflated by the activity.
Upvotes: 0
Reputation: 18112
Create two FrameLayout
in your xml file and place them the way you want. Add fragment in each of them.
Or see this link for nested fragments
Upvotes: 2