Dola TENG 1 gadu atpakaļ
vecāks
revīzija
c869a9e15d

+ 24 - 0
app/src/main/java/com/sambath/sbc/app/MainActivity.kt

@@ -2,11 +2,35 @@ package com.sambath.sbc.app
 
 import androidx.appcompat.app.AppCompatActivity
 import android.os.Bundle
+import android.widget.TextView
+import androidx.navigation.findNavController
+import androidx.navigation.ui.AppBarConfiguration
+import androidx.navigation.ui.setupWithNavController
+import com.google.android.material.bottomnavigation.BottomNavigationView
+import androidx.navigation.ui.setupActionBarWithNavController
 import com.sambath.sbc.R
 
 class MainActivity : AppCompatActivity() {
+
+    lateinit var navView: BottomNavigationView
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_main2)
+
+        navView =  findViewById<BottomNavigationView>(R.id.nav_view)
+        val navController = findNavController(R.id.nav_host_fragment_activity_main)
+        val appBarConfiguration = AppBarConfiguration(
+            setOf(
+                R.id.navigation_home,
+                R.id.navigation_dashboard,
+                R.id.navigation_live,
+                R.id.navigation_event,
+                R.id.navigation_shop
+            )
+        )
+
+        //setupActionBarWithNavController(navController, appBarConfiguration)
+        navView.setupWithNavController(navController)
     }
 }

+ 4 - 1
app/src/main/res/layout/activity_main2.xml

@@ -7,7 +7,9 @@
     android:layout_height="match_parent"
     tools:context=".app.ShareActivity">
 
-    <include layout="@layout/app_bar" />
+    <include
+        android:id="@+id/app_bar"
+        layout="@layout/app_bar" />
 
     <com.google.android.material.bottomnavigation.BottomNavigationView
         android:id="@+id/nav_view"
@@ -26,6 +28,7 @@
         android:name="androidx.navigation.fragment.NavHostFragment"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:layout_marginTop="?attr/actionBarSize"
         app:defaultNavHost="true"
         app:layout_constraintBottom_toTopOf="@id/nav_view"
         app:layout_constraintLeft_toLeftOf="parent"

+ 1 - 0
app/src/main/res/layout/fragment_fighter.xml

@@ -8,6 +8,7 @@
     <!-- TODO: Update blank fragment layout -->
     <TextView
         android:layout_width="match_parent"
+        android:gravity="center"
         android:layout_height="match_parent"
         android:text="@string/hello_blank_fragment" />