Wywoływałęm ją w momencie przechodzenia z jednego fragmentu do drugiego.
private fun editProfileListener(view: View) {
RxView.clicks(view).map {
bottomNavView.visibility = View.GONE
findNavController().navigate(R.id.action_profileFragment_to_userProfileInformationFragment)
}.throttleFirst(1000, TimeUnit.MILLISECONDS).subscribe()
}
<fragment
android:id="@+id/profileFragment"
android:name="com.example.views.home.ProfileFragment"
android:label="fragment_profile"
tools:layout="@layout/fragment_profile" >
<action
android:id="@+id/action_profileFragment_to_userProfileInformationFragment"
app:destination="@id/userProfileInformationFragment" />
</fragment>
<fragment
android:id="@+id/userProfileInformationFragment"
android:name="com.example.views.other.UserProfileInformationFragment"
android:label="fragment_user_profile_information"
tools:layout="@layout/fragment_user_profile_information" >
<action
android:id="@+id/action_userProfileInformationFragment_to_profileFragment"
app:destination="@id/profileFragment" />
</fragment>
Chcę przejśc z ProfileFragment do UserProfileInformationFragment i w UserProfileInformationFragment ukryć nawigacje.
Spróbowałem we fragmencie UserProfileInformationFragment ale wywaliło java.lang.IllegalStateException: bottomNavView must not be null:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
bottomNavView.visibility = View.GONE
}
Spróbowałem jeszcze w klasie mojego activity gdzie są wszystkie inne fragmentu użyć funkcji
private fun setupNav() {
val navController = Navigation.findNavController(this, R.id.bottomNavigationFragment)
bottomNavView.setupWithNavController(navController)
navController.addOnDestinationChangedListener { _, destination, _ ->
when (destination.id) {
R.id.userProfileInformationFragment -> bottomNavView.visibility = View.GONE
else -> bottomNavView.visibility = View.VISIBLE
}
}
}
Gdy uzyję jej w metodzie
onCreateView
aplikacja działa ale nawigacja się nie chowa.
Gdy uzyję jej w
onCreate
logi wywalaja ID does not reference a View inside this Activity