When using anko selector as provided in the examples it is not working
val countries = listOf("Russia", "USA", "Japan", "Australia")
selector("Where are you from?", countries) { i ->
toast("So you're living in ${countries[i]}, right?")
}
here when defining the lambda function it says expected two types of arguments. (Dialoginterface and int). I am stuck with this. Alos the default kotlin alertdialog is saying the same thing. Can anywone solve this issue or tell me how to build an alert dialog with selection in kotlin?
Seems like it's a mistake in the example.
The selector
function source says it expects (DialogInterface, Int) -> Unit
, a function with two parameters, so you can fix your code by adding the missing parameter as follows:
selector("Where are you from?", countries) { dialogInterface, i -> /* ... */ }
Or, if you don't use the DialogInterface
, just ignore it with an underscore:
selector("Where are you from?", countries) { _, i -> /* ... */ }