Android AlertDialog setView,kotlin
文章来源地址https://www.toymoban.com/news/detail-534520.html
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text"
android:textSize="50sp"
android:layout_width="match_parent"
android:layout_height="100dp"
android:hint="please input..." />
</com.google.android.material.textfield.TextInputLayout>
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val alertDialog: AlertDialog = AlertDialog.Builder(this).create()
alertDialog.setTitle("my title")
val view = LayoutInflater.from(this).inflate(R.layout.input_layout, null, false)
alertDialog.setView(view)
alertDialog.setButton(
DialogInterface.BUTTON_POSITIVE,
"ok",
fun(dialog: DialogInterface, which: Int) {
dialog.dismiss()
}
)
alertDialog.setButton(
DialogInterface.BUTTON_NEGATIVE,
"cancel",
fun(dialog: DialogInterface, which: Int) {
dialog.dismiss()
}
)
alertDialog.show()
}
}
Android DialogFragment(1)_zhangphil的博客-CSDN博客Android DialogFragment(1)和过去的AlertDialog类似,Android引入的DialogFragment旨在为开发者提供一个“富”dialog,而不必受到过去Android AlertDialog的局限。首先,DialogFragment是一个Fragment,它有Fragment的一切属性和生命周期,其次,DialogFragment具有和AlertDihttps://blog.csdn.net/zhangphil/article/details/50886077
Android DialogFragment(2)_zhangphil的博客-CSDN博客Android DialogFragment(2)附录文章1简单介绍了如何实现一个DialogFragment,本文再介绍一种简单的方法:直接重写DialogFragment的onCreateDialog返回一个AlertDialog实现对话框。本文的例子和附录文章1不同的地方:不在依赖onCreateView。代码运行逻辑简述:功能简单,当点击FloatingActionButthttps://blog.csdn.net/zhangphil/article/details/50923828
Android Activity调整改变成Dialog_activity改成dialog_zhangphil的博客-CSDN博客做一个style配置到style.xml,直接作为该Activity的android:theme配置即可。具体的style: <style name="DialogActivity" parent="@style/Theme.AppCompat.Dialog"> <item name="android:windowFullscreen">true<...https://blog.csdn.net/zhangphil/article/details/80258149文章来源:https://www.toymoban.com/news/detail-534520.html
到了这里,关于Android AlertDialog setView,kotlin的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!