【发布时间】:2018-06-03 17:23:59
【问题描述】:
我尝试做一个底部导航,我有这个代码
val bottomNavigation = findViewById<View>(R.id.bottom_navigation) as
BottomNavigationView
bottomNavigation.setOnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.botom__nav__home ->
// Action when tab 1 selected
val intent = Intent(this, HomeActivity::class.java)
R.id.botom__nav__profile ->
// Action when tab 2 selected
val intent = Intent(this, LikeActivity::class.java)
else ->
// Action when tab 3 selected
val intent = Intent(this, ProfileActivity::class.java)
}
true
}
startActivityForResult(intent, 99)
}
我有这些错误:
' Expecting an expression '
' Expecting "->" '
对于“When”中的每个元素...
有人可以帮我解决这些错误吗?
【问题讨论】:
-
请参阅下面的 donfuxx 回答。或者将 -> 之后的每个元素括在花括号 {val intent....}
标签: java android mobile kotlin navigation