public void setTextAppearance (Context context, int resId) Added in API level 1
This method was deprecated in API level 23. Use setTextAppearance(int) instead.
我的问题:为什么它被弃用了?为什么它不再需要 Context
了?最重要的是,旧版本如何使用setTextAppearance(int resId)
?
最佳答案
您可以使用 support/androidX 库中的 TextViewCompat
:
import android.support.v4.widget.TextViewCompat // for support-library
import androidx.core.widget.TextViewCompat // for androidX library
// ...
TextViewCompat.setTextAppearance(view, resId)
在内部,它从 API < 23 上的 View (view.getContext()
) 获取上下文。
关于android - 在 API 级别 23 中不推荐使用 setTextAppearance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33581814/