按钮 setTextAppearance(Context context, int resid) 已弃用
和 setTextAppearance(int resid) - 仅适用于 API 级别 23
我应该改用什么?
最佳答案
Deprecated 意味着将来有时会放弃对它的支持,但它仍然按预期工作。在较旧的 API 上,别无选择,因为新的 setTextAppearance(int resid)
仅在 API 级别 23 时发布。
如果想长期安全,可以使用如下代码:
if (Build.VERSION.SDK_INT < 23) {
yourButton.setTextAppearance(context, resid);
} else {
yourButton.setTextAppearance(resid);
}
此代码在 API 级别 23 或更高级别的手机上优先使用新版本,但在 API 级别 23 不可用时使用旧版本。
关于android - 按钮 setTextAppearance 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33393137/