我有一个问题,通过使用AND和OR来比较字符串.如果评论为空并且"规则"等于"A"或"B"或"C",我想显示错误.这意味着,如果"规则"等于除"A","B"或"C"以及"注释"之外的其他任何内容都是空的,那很好,但在其他情况下,它应该显示错误.
此时,&&只能使用equals.("C")和isEmpty.我无法同时使用"A"和"B"...
结果是如果等于A并且注释不为空,则错误仍然出现,对于B同样适用于C ...
String comment = commentet.getText().toString();
if (rule.equals("A") || rule.equals("B") || rule.equals("C") && TextUtils.isEmpty(commentaire)) {
commentet.setError("Comment is necessary");
return;
}
Run Code Online (Sandbox Code Playgroud)
你知道如何解决这个问题吗?
谢谢你的帮助.