[英]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).有一个包含 2 个片段(家庭片段、笔记片段)的主要活动。
I am going from note fragment to another activity called AddNoteActivity .我将从笔记片段转到另一个名为AddNoteActivity的活动。
After I click a button in the AddNoteActivity I want the screen to show the main activity with the note fragment.单击 AddNoteActivity 中的按钮后,我希望屏幕显示带有注释片段的主要活动。
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.我知道这段代码将启动主要活动,但它会自动加载主片段,因为它在 moblie_navigation.xml 中设置为
app:startDestination
startDestination。
How would I get the main activity to load up the note fragment upon button click in the AddNoteActivity?在 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.
当我单击向上箭头时,我将 go 回到原来的注释片段。
For go to the fragment just write对于 go 到片段只需写
on your button click {在您的按钮上单击 {
finish();结束();
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.