I have this piece of Java code:
MaterialDialog builder = new MaterialDialog.Builder(MainActivity.this)
I want to get the MainActivity object in Kotlin. The automatic conversion breaks at MainActivity.this
.
I have this piece of Java code:
MaterialDialog builder = new MaterialDialog.Builder(MainActivity.this)
I want to get the MainActivity object in Kotlin. The automatic conversion breaks at MainActivity.this
.
You can get a reference to your MainActivity
object in Kotlin by using a qualified this
. e.g.:
class MyActivity : MainActivity() {
val builder = MaterialDialog.Builder(this@MyActivity)
}