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)
}
Try this label instead
this@YourActivityName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With