android - 如何在此对话框中开始另一个活动?
问题描述
当我单击“确定”按钮时,我想进入“PickSeatActivity”。这是我尝试过的,但是 android studio 用红线强调了“意图”对象
val builder = AlertDialog.Builder(this.requireActivity())
// Dialog will have "Make a selection" as the title
builder.setMessage("Details successfully captured.Do you wish to proceed and book your seat?")
.setPositiveButton("OK") { dialogInterface: DialogInterface, i: Int ->
val intent = Intent(PickSeatActivity::class.java)
startActivity(intent)
}
// A "Cancel" button that does nothing
.setNegativeButton("Cancel") { dialog, id ->
// Nothing happening here either
}
解决方案
替换你的代码
val intent = Intent(PickSeatActivity::class.java)
startActivity(intent)
到
val intent = Intent(this.requireActivity(), PickSeatActivity::class.java)
startActivity(intent)
推荐阅读
- ejabberd - Ejabberd 17.12 内存泄漏
- performance - 为什么 Iterable.sum() 在 Kotlin 中很慢?
- c# - 使用 0M 而不是 0 作为十进制值?
- sql - POSTGRESQL 限制给定条件的结果查询
- reactjs - 为 cookie 管理创建单独的反应组件
- javascript - 检查值等于数组中的特定值 - javascript
- ms-word - 通过 VBA 更新 WORD 2016 中图片的多个源链接
- excel - Excel VBA:如何在同一列中交换两个选定的单元格范围(不仅仅是两个值)?
- facebook - 从“自己的”Facebook 页面的时间线中阅读公开帖子 - Pages API 需要审核和业务验证
- google-chrome - 谷歌浏览器对 URL 中“#”的新处理将如何影响我的 OpenUI5 应用程序?