In this question there is one line,
findViewById(R.id.go_to_play_store).setOnClickListener(this::goToPlayStore);
how does this line is exactly handling the click listener ?
Java8 introduces concept of Method references and Functional interfaces. If function onClickListener
requires a function with one argument(a.k.a Functional Interface) then if return types and argument types match your function(which is goToPlayStore) then you can pass its reference as functional interface.
This is the new JAVA 8 language feature Lambda Expressions.
:: refer to a new syntax in Java 8 known as method references. You can reference a class or instance and pass along the method that will handle the event
On click its calling function called goToPlayStore () located in that activity or fragment.
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