This is my very first time using Kotlin/Android App Development, so I apologise if I am missing something simple. I have a background in Java and C#.
I'm trying to display an AlertBox containing X information. All the tutorials I am reading/watching stay that the constructor should be:
val builder = AlertDialog.Builder(this)
This issue I am having trouble with is the "this" part. I get a Type Mismatch error for the "this" reference.
I have tried searching for a solution and I find variations of the same:
Instead of passing "this" pass the Context of Calling Activity or Application.
something like,
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
The problem is: I don't understand what I am supposed to enter. I have tried writing "mContext" (I didn't expect this to work) "Employee" (The name of the class) and "MainActivity", but none of these seem to work.
The structure of my code is something like:
class MainActivity : AppCompactActivity() {
class Employee() {
companion object {
}
fun main(args: Array<String>) {
val alertDialogBuilder = AlertDialog.Builder(this)
}
}
}
Thanks for taking the time to look over this and help out.