简体   繁体   中英

Intent from Fragment to Activity - Android Java

I have an activity wherein there is a button to go back to a fragment. I am not getting to know how to do so, even though I searched the web for it.

This is my java code:

public void goBackToNavigationSettings(View v) {
    FragmentManager goBackToNavigationSettings = getFragmentManager();
    goBackToNavigationSettings.beginTransaction().replace(R.id.navigation_settings, new 
    Fragment()).commit();
}

I even tried the normal Intent code but did not work out.

Can someone please help me with this?

使用getSupportFragmentManager()而不是getFragmentManager()

您有点不了解活动/片段的含义 我建议使用单个活动应用程序,然后使用本指南通过片段构建导航

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