将Kotlin类集成到底部导航活动中

时间:2018-12-07 19:41:19

标签: android android-studio kotlin kotlin-android-extensions

我创建了kotlin底部导航活动,然后单击底部导航按钮,然后尝试显示kotlin主题类。单击底部主题底部后,我不确定如何添加subject.kt类。请分享您的想法。

Student.kt
class StudentNames : AppCompatActivity(){

    private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
        when (item.itemId) {
            R.id.navigation_home -> {
                message.setText(R.string.title_home)
//replaceFragment(StudentMenuList())
                return@OnNavigationItemSelectedListener true
            }
            R.id.navigation_dashboard -> {
                message.setText(R.string.title_dashboard)
                return@OnNavigationItemSelectedListener true
            }
            R.id.navigation_notifications -> {
                message.setText(R.string.title_notifications)
                return@OnNavigationItemSelectedListener true
            }
        }
        false
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_Student_names)

        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
//        replaceFragment(StudentMenuList())

    }

}

0 个答案:

没有答案