大佬教程收集整理的这篇文章主要介绍了android-studio – 为什么AS告诉我`(ob instanceof Button)`总是`false`?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
此外,它给出了“投射到按钮”的“提示”.如果我接受提示,没有任何改变.
void setTextSizeForField(int textSize,Object ... obs){ for(Object ob: obs) if (ob instanceof EditText) ((EditText) ob).setTextSize ( textSize ); else if (ob instanceof TextView) ((TextView) ob).setTextSize ( textSize ); else if (ob instanceof Button) ((Button) ob).setTextSize ( textSize/10 ); }
消息的全文是:
Condition 'ob instanceof Button' is always 'false' less... (Ctrl+F1) This inspection analyzes method control and data flow to report possible conditions that are always true or false,expressions whose value is statically proven to be constant,and situations that can lead to nullability contract violations. Variables,method parameters and return values marked as @Nullable or @NotNull are treated as nullable (or not-null,respectively) and used during the analysis to check nullability contracts,e.g. report possible NullPointerException errors. More complex contracts can be defined using @Contract Annotation,for example: @Contract("_,null -> null") — method returns null if its second argument is null @Contract("_,null -> null; _,!null -> !null") — method returns null if its second argument is null and not-null otherwise @Contract("true -> fail") — a typical assertfalse method which throws an exception if true is passed to it The inspection can be configured to use custom @Nullable @NotNull Annotations (by default the ones from Annotations.jar will be used)
我没有使用注释.
*编辑*
如果我交换其他两个if语句,我得不到警告,代码运行正常.
所以我猜“没关系”可能是有序的,但你认为AS在做什么?
以上是大佬教程为你收集整理的android-studio – 为什么AS告诉我`(ob instanceof Button)`总是`false`?全部内容,希望文章能够帮你解决android-studio – 为什么AS告诉我`(ob instanceof Button)`总是`false`?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。