我必须向客户端显示一个弹出窗口,当未添加 mobilePhone 和 profileDetails 时,两个弹出窗口应一一显示(当 1 完成时) ,那么应该显示2,如果都完成了,则不会弹出窗口)
所以,我有以下代码:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
....
if (userDTO.getMobile().isEmpty() && artistDetailsDTO.getCategoryID().isEmpty() {
show popup to fill up a profile
}
}
if(userDTO.getMobile().isEmpty() && artistDetailsDTO.getCategory_id().matches("[0-9]+")) {
show popup to add a mobile phone
}
当用户填写类别ID并再次打开此页面时,用户仍然会收到一个弹出窗口来填写他的个人资料。
但是上面我已经提到了 &&artistDetailsDTO.getCategory_id().matches("[0-9]+")) {
据我了解,当两个条件都成立时,它应该出现,但在我的情况下,移动设备为空,但类别ID不为空。
还是我做错了什么?
我所期望的,onCreateView
我应该检查:
1. if mobileIsEmpty + categoryIDisEmpty == show popup to fill profile.
2. if mobileIsEmpty + categoryID**NOT**Empty == show popup to fill mobile
3. if mobileIs**NOT**empty + categoryID**NOT**Empty == show nothing
我做了很多变体.. && , ^ , & , !它们都不能正确工作。
期待,有任何建议。
谢谢!
最佳答案
那就这么做吧
if(mobileIsEmpty){
if(categoryIDisEmpty ){
show popup to fill profile
}else {
how popup to fill mobile
}
}else if(categoryID**NOT**Empty) {
show nothing
}
最后如果没有其他条件就不能使用
关于java - 如何正确检查2 -3个条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55509610/