按钮setTextAppearance是德precated [英] Button setTextAppearance is deprecated

查看:828
本文介绍了按钮setTextAppearance是德precated的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按钮setTextAppearance(上下文的背景下,INT渣油)为德precated

Button setTextAppearance(Context context, int resid) is deprecated

和setTextAppearance(INT渣油) - 仅适用于API级别23

and setTextAppearance(int resid) - only available for API level 23

我应该用什么呢?

推荐答案

德precated手段支持将是它有时会在未来下降,但预期仍能工作。在旧的API,没有别的选择,因为新的 setTextAppearance(INT渣油)只拿到了发布了API级23。

Deprecated means that support will be dropped for it sometimes in the future, but it is still working as expected. On older APIs, there is no alternative, since the new setTextAppearance(int resid) got only released with API level 23.

如果你想成为很长一段时间的安全,你可以使用下面的code:

If you want to be safe for a long time, you can use the following code:

if (Build.VERSION.SDK_INT < 23) {
    yourButton.setTextAppearance(context, resid);
} else {
    yourButton.setTextAppearance(resid);
}

这code prefers在手机上新版本的API级别23或更高,但使用旧的时API级别23一个是不可用的。

This code prefers the new version on phones with API level 23 or higher, but uses the old one when the API level 23 one isn't available.

这篇关于按钮setTextAppearance是德precated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆