简体   繁体   中英

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 !

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM