diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java b/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java index 96f0e93..02b84ae 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/MainActivity.java @@ -1,8 +1,11 @@ package cc.niushuai.project.devcontrol; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.navigation.NavController; +import androidx.navigation.NavDestination; import androidx.navigation.Navigation; import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.ui.AppBarConfiguration; @@ -10,6 +13,7 @@ import androidx.navigation.ui.NavigationUI; import android.os.Bundle; import android.view.Menu; +import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; @@ -57,6 +61,14 @@ public class MainActivity extends AppCompatActivity { // 返回键 左上角以及右上角 // NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); + // 页签点击监听 +// navController.addOnDestinationChangedListener(new NavController.OnDestinationChangedListener() { +// @Override +// public void onDestinationChanged(@NonNull NavController navController, @NonNull NavDestination navDestination, @Nullable Bundle bundle) { +// Toast.makeText(MainActivity.this, "onDestinationChanged Called: " + navDestination.getDisplayName(), Toast.LENGTH_SHORT).show(); +// } +// }); + // 底部导航栏 BottomNavigationView bottomNavView = this.findViewById(R.id.bottom_nav_view); diff --git a/app/src/main/res/menu/main_nav_menu.xml b/app/src/main/res/menu/main_nav_menu.xml index 11feae3..3c73b34 100644 --- a/app/src/main/res/menu/main_nav_menu.xml +++ b/app/src/main/res/menu/main_nav_menu.xml @@ -2,17 +2,17 @@