在kotlin中打开alertDialog,如何设置单选按钮的消息
试图在kotlin中打开一个alertDialog,对话框需要显示标题和一些文本消息以及一些单选按钮列表。
使对话框部分工作,但不能设置消息(正文),如果设置消息,那么单选按钮将不会显示(???)。
我想这可能是alertDialog的限制,或任何人都知道解决?
fun openAlertDialog(title: String, alertMessage: String, items: ArrayList<String>) { val poistion = 0 val alertDilogBuilder = AlertDialog.Builder(activity, R.style.myDialogeTheme) alertDilogBuilder.setTitle(title) //alertDilogBuilder.setMessage(alertMessage) //<== if setMessage the radio button will not show .setSingleChoiceItems(list, poistion, object : DialogInterface.OnClickListener { override fun onClick(dialog: DialogInterface, index: Int) { onSelectedCategory(items[index]) Toast.makeText(activity.applicationContext, items[index], Toast.LENGTH_SHORT).show() dialog.dismiss() } }) alertDialog = alertDilogBuilder.create() alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, “Ok", { dialogInterface, i -> onSelectedCategory(items[0]) }) alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Cancel", { dialogInterface, k -> dialogInterface.dismiss() }) alertDialog!!.show() }
- 升级到kotlin RC1(1.0.0-rc-1036)之后的java.lang.IncompatibleClassChangeError
- Rxjava与kotlin
- 使用编译“org.jetbrains.kotlin:kotlin-stdlib-jre7:$ kotlin_version”给错误
- 修改内部类的全局变量的值
- 在onCreateView android视图是null
- Android Retrofit + Google Places API(文本搜索)
- 错误:com.app.android.dagger.component.AppComponent(unscoped)可能不引用作用域绑定:
- 如何使用Android kotlin仅在日期选取器对话框中显示日期和月份
- 使用Kotlin在Android中添加数字