我的底部导航代码正常运行,但是交换无效,如何添加交换代码?
我在Kotlin中使用了片段导航和底部导航
private val mOnNavigationItemSelectedListener=BottomNavigationView.OnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.navigation_shop -> {
// toolbar!!.title="live Track"
fragment=StoreFragment()
loadFragment(fragment)
return@OnNavigationItemSelectedListener true
}
R.id.navigation_gifts -> {
//toolbar!!.title="Team Management"
fragment=GiftsFragment()
loadFragment(fragment)
return@OnNavigationItemSelectedListener true
}
R.id.navigation_cart -> {
//toolbar!!.title="All task"
fragment=CartFragment()
loadFragment(fragment)
return@OnNavigationItemSelectedListener true
}
R.id.navigation_profile -> {
// toolbar!!.title="Report"
fragment=ProfileFragment()
loadFragment(fragment)
return@OnNavigationItemSelectedListener true
}
}
true
}
答案 0 :(得分:1)
底部导航栏不应为您的片段提供滑动。如果要滑动,则必须在导航栏中使用view-pager。
看看 https://developer.android.com/reference/android/support/v4/view/ViewPager