package com.shyptsolution.alertdialogbox
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var button=findViewById<Button>(R.id.button)
button.setOnClickListener {
var builder=android.app.AlertDialog.Builder(this)
builder.setTitle("Title")
builder.setMessage("MEssage")
builder.setIcon(android.R.drawable.ic_delete)
builder.setPositiveButton("Yes"){
dialoginterface, which->
var textview=findViewById<TextView>(R.id.textView)
textview.setText("CLicked")
}
builder.setNegativeButton("No"){
dialoginterface,which->
}
builder.setNeutralButton("OK"){
dialoginterface,which->
}
var alertdialog=builder.create()
alertdialog.setCancelable(false)
alertdialog.show()
}
}
}
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.