I have been working on an Android project in Kotlin and would like to use this UI library. However, it’s written in Java (and so is the documentation), and I’m not sure how to implement the event listener for the buttons. This is how it’s supposed to be done in Java:
final CircleMenuView menu = (CircleMenuView) findViewById(R.id.circle_menu); menu.setEventListener(new CircleMenuView.EventListener() { @Override public void onMenuOpenAnimationStart(@NonNull CircleMenuView view) { Log.d("D", "onMenuOpenAnimationStart"); } }
Does anyone know how I could do the same in Kotlin? Thanks
Advertisement
Answer
You can just paste the code in Android Studio and it will suggest to you to convert it to Kotlin code
The same code in Kotlin will be like this
val menu = findViewById<CircleMenuView>(R.id.circle_menu) menu.setEventListener(object : CircleMenuView.EventListener { override fun onMenuOpenAnimationStart(view : CircleMenuView) { Log.d("D", "onMenuOpenAnimationStart"); } })