You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
package com.example.shakecraft
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import android.os.Bundle
|
|
import androidx.fragment.app.Fragment
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
|
|
class MainActivity : AppCompatActivity() {
|
|
lateinit var bottomNav : BottomNavigationView
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_main)
|
|
loadFragment(HomeFragment())
|
|
bottomNav = findViewById(R.id.bottomNav) as BottomNavigationView
|
|
bottomNav.setOnItemSelectedListener {
|
|
when (it.itemId) {
|
|
R.id.home -> {
|
|
loadFragment(HomeFragment())
|
|
true
|
|
}
|
|
R.id.inventory -> {
|
|
loadFragment(InventoryFragment())
|
|
true
|
|
}
|
|
R.id.plus -> {
|
|
loadFragment(PlusFragment())
|
|
true
|
|
}
|
|
else -> false
|
|
}
|
|
}
|
|
}
|
|
private fun loadFragment(fragment: Fragment){
|
|
val transaction = supportFragmentManager.beginTransaction()
|
|
transaction.replace(R.id.container,fragment)
|
|
transaction.commit()
|
|
}
|
|
|
|
|
|
} |