안녕하세요. 바텀네비게이션 Action 관련 질문입니다.
먼저 Bottom Navigation은 SettingFragment, DashBoardFragment, NotificationFragment로 설정되어 있는 상태입니다.
SettingFragment 화면에서 버튼을 누르면 DashBoardFragment로 이동하게 설계를 하였는데요.
문제점은, 이후에 바텀네비게이션에서 SettingFragment 항목을 누르면 해당 항목으로 이동되지 않는 현상입니다. 어떤 문제가 있는 것일까요?
MainActivity ↓
val navHostFragment =
supportFragmentManager.findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment
val navController = navHostFragment.navController
findViewById<BottomNavigationView>(R.id.nav_view)
.setupWithNavController(navController)
fun move() {
val navController = findNavController(R.id.nav_host_fragment_activity_main)
navController.navigate(R.id.action_navigation_setting_to_navigation_dashboard)
}
Navigation.xml ↓
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mobile_navigation"
app:startDestination="@+id/navigation_setting">
<fragment
android:id="@+id/navigation_setting"
android:name="com.nex.nmp.ui.setting.SettingFragment"
android:label="@string/title_setting"
tools:layout="@layout/fragment_setting">
<action
android:id="@+id/action_navigation_setting_to_navigation_dashboard"
app:destination="@id/navigation_dashboard" />
</fragment>
<fragment
android:id="@+id/navigation_dashboard"
android:name="com.nex.nmp.ui.dashboard.DashboardFragment"
android:label="@string/title_dashboard"
tools:layout="@layout/fragment_dashboard" />
<fragment
android:id="@+id/navigation_notifications"
android:name="com.nex.nmp.ui.notifications.NotificationsFragment"
android:label="@string/title_notifications"
tools:layout="@layout/fragment_notifications" />
</navigation>