微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我不知道为什么我的菜单项在我点击后没有响应

如何解决我不知道为什么我的菜单项在我点击后没有响应

I think my code is nothing error but my menu item cant intent me to another page or activity

override fun onoptionsItemSelected(item: MenuItem): Boolean {
        id = item.itemId
        if (id == R.id.myAccount){
            val intent = Intent(this,HomeActivity::class.java)
            this.startActivity(intent)
            return true
        }
        else if (id == R.id.myTransaction){
            val intent = Intent(this,TransactionActivity::class.java)
            this.startActivity(intent)
            return true
        }

        return super.onoptionsItemSelected(item)
    }

override fun onCreate(savedInstanceState: Bundle?,persistentState: PersistableBundle?) {
    super.onCreate(savedInstanceState,persistentState)
    setContentView(R.layout.activity_home)
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
    menuInflater.inflate(R.menu.nav_drawer_menu,menu)
    return super.onCreateOptionsMenu(menu)
}

感谢您的回复和关注

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。