Home > Net >  Which component designates the entry point of an activity?
Which component designates the entry point of an activity?

Time:06-14

enter image description here

The app I'm working on has several tabs on the bottom,and they're all part of the same Activity. Upon launching the app, the first tab to get the focus is always the same one. I want to know which component of the app makes it behave that way.

CodePudding user response:

You can go to the navigation resource directory in res folder and find the navigation file which associated with this behavior. Open the navigation file and there you will see multiple <fragments listed.

At the top of this file you will find a <navigation block which will have something like app:startDestination="@ id/"ID"

In your file you will find something else at the place of ID and that is the id of the fragment which will come first when you open the activity.

So for you answer it is app:startDestination which is responsible for giving the focus to the first fragment when you launch the app.

  • Related