简体   繁体   中英

Acivity1 Fragment2 -> Activity2 (after button click) -> Activity1 Fragment2 navigate from activity to specific fragment

Hello I have an application that implements bottom navigation component.

There is a main activity with 2 fragments (home fragment, note fragment).

I am going from note fragment to another activity called AddNoteActivity .

After I click a button in the AddNoteActivity I want the screen to show the main activity with the note fragment.

Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);

I understand that this code will launch the main activity but it automatically loads the home fragment because of its set as the app:startDestination in moblie_navigation.xml.

How would I get the main activity to load up the note fragment upon button click in the AddNoteActivity?

Also I have an action bar with up on navigation enabled. When I click the up arrow, I go back to the note fragment like its supposed to.

For go to the fragment just write

on your button click {

finish();

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM