java - 如何正确检查2 -3个条件?

标签 java android android-fragments

我必须向客户端显示一个弹出窗口,当未添加 mobilePhoneprofileDetails 时,两个弹出窗口应一一显示(当 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/

相关文章:

java - 在 Eclipse 编辑器中鼠标悬停时显示指令/功能信息

android - 弯曲的 ListView 分隔线

android - 导入 com.microsoft.windowsazure.messaging.*;未检测到。我应该在 android studio 中添加哪个库?

android - 如何使用 Swipe Tab 通过不同的 Fragments 进行通信/传递数据?

java - 使用 Java 连接到 C++ 程序

java - 为什么这个字符串到数组不起作用?

java - 在 map 中使用模板

java - ArrayList 使用 Bundle 传递 null

Android 支持警报对话框更改标题背景颜色?

android - 未调用子 fragment 的 setUserVisibleHint 和 onResume