package com.shyptsolution.prathamgandhi

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.widget.*
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 {
try {
val view = LayoutInflater.from(this)
.inflate(R.layout.nativead, null, false)

val builder = AlertDialog.Builder(this)
builder.setTitle("You can't delete this post!!")
builder.setMessage("It seems you are not the one who really posted this. Please contact who posted this.")
// builder.setIcon(R.drawable.)
builder.setPositiveButton("Delete for me.") { dialogInterface, which ->

// notifyDataSetChanged()
}
builder.setNegativeButton("Ok") { dialogInterface, which ->
}
// Create the AlertDialog
val alertDialog: AlertDialog = builder.create()


// Set other dialog properties
alertDialog.setView(view)
alertDialog.setCancelable(false)
alertDialog.show()

} catch (e: Exception) {
e.stackTrace
Toast.makeText(
this,
e.toString(),
Toast.LENGTH_LONG
).show()
}
}

button.setOnClickListener {
var inflater=LayoutInflater.from(this)
var popupview=inflater.inflate(R.layout.example,null,false)
// var imagee=popupview.findViewById<ImageView>(R.id.imageinpopup)
// imagee.setImageResource(R.drawable.image)
// var close=popupview.findViewById<ImageView>(R.id.close)
var builder= PopupWindow(popupview, LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT,true)
builder.setBackgroundDrawable(getDrawable(R.drawable.background))
// builder.animationStyle=R.style.DialogAnimation
builder.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER,0,0)
// close.setOnClickListener {
// builder.dismiss()
// }
}
}
}