Код: Выделить всё
Fatal Exception: java.lang.IllegalArgumentException
Navigation action/destination com.packagename:id/dietListToExercise cannot be found from the current destination h(com.packagename:id/fragment_exercise) label=ExerciseFragment class=com.packagename.fragment.ExerciseFragment
androidx.navigation.NavController.navigate (NavController.java:1691)
androidx.navigation.NavController.navigate (NavController.java:1574)
com.packagename.activity.MainActivity.lambda$onCreate$5 (MainActivity.java:256) //256.line
com.google.android.material.navigation.NavigationBarView$1.onMenuItemSelected (NavigationBarView.java:311)
Код: Выделить всё
navController = Objects.requireNonNull(((NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView))).getNavController();
mainBinding.bottomNavigationView.setOnItemSelectedListener(item -> {
if (isMenuItemClickable) {
int itemId = item.getItemId();
if (itemId == previousMenuItemId) {
return true;
}
previousMenuItemId = itemId;
NavDestination currentDestination = navController.getCurrentDestination();
if (currentDestination != null) {
int currentId = currentDestination.getId();
int destinationId = currentId;
if (itemId == R.id.fragment_daily) {
if (currentId == R.id.fragment_dietlist) {
destinationId = R.id.dietListToDaily;
} else {
destinationId = R.id.exerciseToDaily;
}
} else if (itemId == R.id.fragment_dietlist) {
if (currentId == R.id.fragment_daily) {
destinationId = R.id.dailyToDietList;
} else {
destinationId = R.id.exerciseToDietList;
}
} else if (itemId == R.id.fragment_exercise) {
if (currentId == R.id.fragment_daily) {
destinationId = R.id.dailyToExercise;
} else {
destinationId = R.id.dietListToExercise;
}
}
Log.d("NavControllerDebug", "currentId: " + currentId + ", destinationId: " + destinationId);
navController.navigate(destinationId);//256.line here is
isMenuItemClickable = false;
new Handler().postDelayed(() -> isMenuItemClickable = true, 1500);
}
return true;
} else {
Toast.makeText(this, "Please wait...", Toast.LENGTH_SHORT).show();
return false;
}
});
Код: Выделить всё
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/788 ... destinatio