user7513041
user7513041

Reputation:

Dialog Icon doesn't appear in Kotlin dialog

I have an android app made by kotlin I made a dialog in it and set Icon to this dialog but the icon doesn't appear this is my code :

    val dialogBuilder = AlertDialog.Builder(this)

    dialogBuilder.setTitle("")
    dialogBuilder.setMessage(list[c])
    dialogBuilder.setIcon(R.drawable.cancel)
    dialogBuilder.setCancelable(false)
    dialogBuilder.setPositiveButton("Ok", { _, _ ->
        if(c == list.size)
            finish()
    })

    val b = dialogBuilder.create()
    b.show()
}

Upvotes: 0

Views: 525

Answers (1)

yogesh lokhande
yogesh lokhande

Reputation: 1275

Use Following :

  val dialogBuilder = AlertDialog.Builder(this)

    dialogBuilder.setTitle(" ")
    dialogBuilder.setMessage(list[c])
    dialogBuilder.setIcon(R.drawable.cancel)
    dialogBuilder.setCancelable(false)
    dialogBuilder.setPositiveButton("Ok", { _, _ ->
        if(c == list.size)
            finish()
    })

    val b = dialogBuilder.create()
    b.show()
}

Upvotes: 1

Related Questions