How to Set a Home Screen Fragment for Android App

Asked

Viewed 268 times

-1

I created an APP with a drawer menu, that menu drawable that appears as a template when creating a project in Android Studio. I managed to create the fragments and relate to the menu, is working beauty, my problem is that I can not define my fragment "home" as initial, for example, when opening the application wanted to be loaded this fragment.

1 answer

2


To define a fragment initial, just use the FragmentTransaction in his onCreate(). See below for an example:

ExemploFragment fragment = new ExemploFragment();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_exemplo, fragment);
fragmentTransaction.commit();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.