首页 > 解决方案 > jumpDrawablesToCurrentState(View) 在 Android 中已弃用

问题描述

检查单选按钮后,我想调用jumpDrawablesToCurrentState(View)方法,但似乎不推荐使用此方法。

这种方法的新api是什么?

代码:

if (currentLanguage.equals(getString(R.string.LANGUAGE_ENGLISH), ignoreCase = true)) {
   settingsRadiogroup.check(radioButtonEn.id)
   jumpDrawablesToCurrentState(settingsRadiogroup) //deprecated
} else {
   settingsRadiogroup.check(radioButtonBn.id)
   jumpDrawablesToCurrentState(settingsRadiogroup) //deprecated
}

标签: androidkotlin

解决方案


我认为jumpDrawablesToCurrentState()里面是通过一个 Drawable 。在此处引用开发人员文档:

此方法在 API 级别 27.1.0 中已弃用。直接使用 jumpToCurrentState() 。调用 Drawable.jumpToCurrentState()。

所以在这种情况下,settingsRadiogroup.jumpDrawablesToCurrentState()不应该表现出任何弃用。


推荐阅读