A more simpler solution by using lambda.
Inside CircleShape.kt
, declare a lambda function.
var listener: (()->Unit)? = null
...
// When you want to invoke the listener
listener?.invoke()
Inside your Activity
mCircleShape.listener = {
// Do something when you observed a call
}
More Related Contents:
- Translate java widget to kotlin [duplicate]
- Room database created in Kotlin, activity written in Java, can I do that?
- Formatting Double to String? [duplicate]
- Unfortunately MyApp has stopped. How can I solve this?
- Why does my function that calls an API return an empty or null value?
- Alarm Manager Example
- How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?
- The AsyncTask API is deprecated in Android 11. What are the alternatives?
- How to make an Android device vibrate? with different frequency?
- How can I convert a part of Java source file to Kotlin?
- How can I generate random number in specific range in Android? [duplicate]
- Why does my function that calls an API or launches a coroutine return an empty or null value?
- How to use interface to communicate between two activities
- Place cursor at the end of text in EditText
- android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify
- Best way to implement View.OnClickListener in Android
- onActivityResult() not called in new nested fragment API
- How can I resolve the error “The minCompileSdk (31) specified in a dependency’s AAR metadata” in native Java or Kotlin? [duplicate]
- JCenter deprecation; impact on Gradle and Android
- How to save an image in Android Q using MediaStore?
- Disable SSL certificate check in retrofit library
- wait until firebase retrieves data [duplicate]
- How to check permission in fragment
- How to exclude an element from a Firestore query?
- Kotlin-android: unresolved reference databinding
- What is the best way to declare on UI component in android with Kotlin?
- Android Failed to instantiate one or more classes
- MediaSessionCompat:Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent
- How can I get the average color of an image?
- How to hide the soft keyboard inside a fragment?