From c3346234fe8bea2bb8df696974e90a3d0a152d7c Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Thu, 13 Oct 2022 14:44:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E6=97=A0=E6=B3=95=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/niushuai/project/devcontrol/MainActivity.java | 12 ++++++++++++ app/src/main/res/menu/main_nav_menu.xml | 6 +++--- app/src/main/res/navigation/main_navigation.xml | 8 ++++---- app/src/main/res/values/ids.xml | 6 +++--- 4 files changed, 22 insertions(+), 10 deletions(-) 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 @@ diff --git a/app/src/main/res/navigation/main_navigation.xml b/app/src/main/res/navigation/main_navigation.xml index 0fe7bcc..f51734c 100644 --- a/app/src/main/res/navigation/main_navigation.xml +++ b/app/src/main/res/navigation/main_navigation.xml @@ -3,20 +3,20 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_navigation" - app:startDestination="@id/navDeviceFragment"> + app:startDestination="@id/bottom_nav_device"> diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 0a28330..48a1b82 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -1,9 +1,9 @@ - - - + + + \ No newline at end of file