user8354597
user8354597

Reputation:

Convert deprecated methods from Java to Kotlin

I am translating a code from Java to Kotlin with Android Studio, but I have the problem.

When I use this:

MenuItemCompat.setOnActionExpandListener(MenuItem.OnActionExpandListener)

Android Studio tells me setOnActionExpandListener is deprecated in Java. So how can I convert this code in Kotlin ?

Thank you !

Upvotes: 0

Views: 718

Answers (1)

tynn
tynn

Reputation: 39853

You read the documentation and do what's suggested to you.

This method was deprecated in API level 26.0.0-beta1.
Use setOnActionExpandListener(MenuItem.OnActionExpandListener) directly.

The setOnActionExpandListener() was added with Android version 14 and since the Support libraries in version 26 requires the same version, there's no need for using it with the compatibility method.

Upvotes: 2

Related Questions