android - 'when' 语句在 Kotlin for Android 中跳过条件

标签 android android-studio kotlin

我一直在使用 kotlin 在 android studio canary 5 上开发应用程序。我正在使用 when 语句来验证注册表单是否有效。

else if(registering) when {
        email.text == null -> email.error = "Enter Email!"
        !isValidEmail(email.text) -> email.error = "Invalid Email!"
        password.text == null -> password.error = "Enter Password!"
        password_conf.text == null -> password_conf.error = "Re-enter Password!"
        password_conf.text.toString() != password.text.toString() -> password_conf.error =
                "Re-enter Password!"
        password_conf.text.toString() != password.text.toString() -> password_conf.error = "Passwords Don't Match!"
        name.text == null -> name.error = "Enter Full Name!"
        branchSelected == "Branch" ->{
            val errorText = branch.selectedView as TextView
            errorText.error = ""
            errorText.setTextColor(Color.RED)
            errorText.text = getString(R.string.select_branch)
        }
        phone.text == null || !isValidPhone(phone.text) -> phone.error = "Enter Valid Phone Number!"
        !isValidReg(reg_number.text) -> reg_number.error = "Invalid Registration Number"
        roll_number.text != null && !isValidRoll(roll_number.text) -> roll_number.error = "Enter Valid roll number!"
        else -> {
            createAccount(email.text.toString(), password.text.toString())
            addDB()
        }
    }

password.text == null -> password.error = "Enter Password!" 由于某种原因不起作用。

我 90% 确定该行是正确的,因为 email.text == null -> email.error = "Enter Email!" 工作得很好,android studio 对变量进行颜色编码。

是否会因为 android studio kotlin 支持处于测试阶段或其他原因而发生错误?

更新:正如 JK Ly 所建议的,以下是电子邮件和密码的值:

(When I kept email empty)

email = {AppCompatEditText@5191} "android.support.v7.widget.AppCompatEditText{c15a402 VFED..CL. .F...... 79,242-1001,360 #7f09003d app:id/email}"
 mBackgroundTintHelper = {AppCompatBackgroundHelper@5243} 
 mTextHelper = {AppCompatTextHelperV17@5244} 
 mAllowTransformationLengthChange = false
 mAutoLinkMask = 0
 mBoring = null
 mBreakStrategy = 0
 mBufferType = {TextView$BufferType@5245} "EDITABLE"
 mChangeWatcher = {TextView$ChangeWatcher@5246} 
 mCharWrapper = null
 mCurHintTextColor = 1627389952
 mCurTextColor = -570425344
 mCurrentSpellCheckerLocaleCache = null
 mCursorDrawableRes = 17303397
 mDeferScroll = -1
 mDesiredHeightAtMeasure = 118
 mDeviceProvisionedState = 0
 mDrawables = null
 mEditableFactory = {Editable$Factory@5247} 
 mEditor = {Editor@5248} 
 mEllipsize = null
 mFilters = {InputFilter[0]@5249} 
 mFreezesText = false
 mGravity = 8388627
 mHighlightColor = 1711314568
 mHighlightPaint = {Paint@5250} 
 mHighlightPath = {Path@5251} 
 mHighlightPathBogus = false
 mHint = "Email"
 mHintBoring = {BoringLayout$Metrics@5253} "FontMetricsInt: top=-50 ascent=-44 descent=11 bottom=13 leading=0 width=116"
 mHintLayout = {BoringLayout@5254} 
 mHintTextColor = {ColorStateList@5255} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[16842910, 16842919], []]mColors=[-1979711488, 1627389952]mDefaultColor=1627389952}"
 mHorizontallyScrolling = true
 mHyphenationFrequency = 1
 mIncludePad = true
 mLastLayoutDirection = 0
 mLastScroll = 0
 mLayout = {DynamicLayout@5256} 
 mLinkTextColor = {ColorStateList@5257} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[]]mColors=[-16738680]mDefaultColor=-16738680}"
 mLinksClickable = true
 mListeners = null
 mLocalesChanged = false
 mMarquee = null
 mMarqueeFadeMode = 0
 mMarqueeRepeatLimit = 3
 mMaxMode = 1
 mMaxWidth = 2147483647
 mMaxWidthMode = 2
 mMaximum = 1
 mMinMode = 1
 mMinWidth = 0
 mMinWidthMode = 2
 mMinimum = 1
 mMovement = {ArrowKeyMovementMethod@5258} 
 mOldMaxMode = 1
 mOldMaximum = 1
 mPreDrawListenerDetached = false
 mPreDrawRegistered = false
 mPreventDefaultMovement = false
 mRestartMarquee = false
 mSavedHintLayout = {BoringLayout@5254} 
 mSavedLayout = null
 mSavedMarqueeModeLayout = null
 mScroller = null
 mShadowColor = 0
 mShadowDx = 0.0
 mShadowDy = 0.0
 mShadowRadius = 0.0
 mSingleLine = true
 mSpacingAdd = 0.0
 mSpacingMult = 1.0
 mSpannableFactory = {Spannable$Factory@5259} 
 mTempRect = {Rect@5260} "Rect(87, 305 - 91, 423)"
 mText = {SpannableStringBuilder@5261} ""
  mFilters = {InputFilter[1]@5289} 
  mGapLength = 10
  mGapStart = 0
  mIndexOfSpan = {IdentityHashMap@5290}  size = 7
  mLowWaterMark = 2147483647
  mOrderSortBuffer = {int[9]@5291} 
  mPrioSortBuffer = {int[9]@5292} 
  mSpanCount = 7
  mSpanEnds = {int[9]@5293} 
  mSpanFlags = {int[9]@5294} 
  mSpanInsertCount = 19
  mSpanMax = {int[7]@5295} 
  mSpanOrder = {int[9]@5296} 
  mSpanStarts = {int[9]@5297} 
  mSpans = {Object[9]@5298} 
  mText = {char[10]@5299} 
  mTextWatcherDepth = 0
  shadow$_klass_ = {Class@529} "class android.text.SpannableStringBuilder"
  shadow$_monitor_ = -2077412599
 mTextColor = {ColorStateList@5262} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[973078528, -570425344]mDefaultColor=-570425344}"
 mTextDir = {TextDirectionHeuristics$TextDirectionHeuristicInternal@5263} 
 mTextEditSuggestionContainerLayout = 17367285
 mTextEditSuggestionHighlightStyle = 16974923
 mTextEditSuggestionItemLayout = 17367287
 mTextPaint = {TextPaint@5264} 
 mTextSelectHandleLeftRes = 17303401
 mTextSelectHandleRes = 17303403
 mTextSelectHandleRightRes = 17303405
 mTransformation = {SingleLineTransformationMethod@5265} 
 mTransformed = {ReplacementTransformationMethod$SpannedReplacementCharSequence@5266} ""
 mUserSetTextScaleX = false
 mAccessibilityCursorPosition = -1
 mAccessibilityDelegate = null
 mAccessibilityTraversalAfterId = -1
 mAccessibilityTraversalBeforeId = -1
 mAccessibilityViewId = -1
 mAnimator = null
 mAttachInfo = {View$AttachInfo@5267} 
 mAttributes = null
 mBackground = {InsetDrawable@5268} 
 mBackgroundRenderNode = {RenderNode@5269} 
 mBackgroundResource = 0
 mBackgroundSizeChanged = false
 mBackgroundTint = null
 mBottom = 360
 mCachingFailed = false
 mClipBounds = null
 mContentDescription = null
 mContext = {LoginActivity@5188} 
 mCurrentAnimation = null
 mDrawableState = {int[4]@5270} 
 mDrawingCache = null
 mDrawingCacheBackgroundColor = 0
 mFloatingTreeObserver = null
 mForegroundInfo = null
 mFrameMetricsObservers = null
 mGhostView = null
 mHasPerformedLongPress = false
 mID = 2131296317
 mIgnoreNextUpEvent = false
 mInContextButtonPress = false
 mInputEventConsistencyVerifier = null
 mKeyedTags = null
 mLabelForId = -1
 mLastIsOpaque = false
 mLayerPaint = null
 mLayerType = 0
 mLayoutInsets = null
 mLayoutParams = {LinearLayout$LayoutParams@5271} 
 mLeft = 79
 mLeftPaddingDefined = false
 mListenerInfo = null
 mLongClickX = NaN
 mLongClickY = NaN
 mMatchIdPredicate = null
 mMatchLabelForPredicate = null
 mMeasureCache = {LongSparseLongArray@5272} "{4611689978387236305=3959959847030}"
 mMeasuredHeight = 118
 mMeasuredWidth = 922
 mMinHeight = 0
 View.mMinWidth = 0
 mNestedScrollingParent = null
 mNextFocusDownId = -1
 mNextFocusForwardId = -1
 mNextFocusLeftId = -1
 mNextFocusRightId = -1
 mNextFocusUpId = -1
 mOldHeightMeasureSpec = 1489
 mOldWidthMeasureSpec = 1073742746
 mOutlineProvider = {ViewOutlineProvider$1@5273} 
 mOverScrollMode = 1
 mOverlay = null
 mPaddingBottom = 29
 mPaddingLeft = 10
 mPaddingRight = 10
 mPaddingTop = 26
 mParent = {LinearLayout@5274} "android.widget.LinearLayout{2b0397d V.E...... ........ 0,0-1080,1997 #7f090000 app:id/SignIn_Layout}"
 mPendingCheckForLongPress = null
 mPendingCheckForTap = null
 mPerformClick = null
 mPointerIcon = null
 mPrivateFlags = 16812082
 mPrivateFlags2 = 1611867688
 mPrivateFlags3 = 4
 mRecreateDisplayList = false
 mRenderNode = {RenderNode@5275} 
 mResources = {Resources@5227} 
 mRight = 1001
 mRightPaddingDefined = false
 mRunQueue = {HandlerActionQueue@5276} 
 mScrollCache = null
 mScrollIndicatorDrawable = null
 mScrollX = 0
 mScrollY = 0
 mSendViewScrolledAccessibilityEvent = null
 mSendViewStateChangedAccessibilityEvent = null
 mSendingHoverAccessibilityEvents = false
 mStartActivityRequestWho = null
 mStateListAnimator = null
 mSystemUiVisibility = 0
 mTag = null
 mTempNestedScrollConsumed = null
 mTop = 242
 mTouchDelegate = null
 mTouchSlop = 21
 mTransformationInfo = {View$TransformationInfo@5277} 
 mTransientStateCount = 0
 mTransitionName = null
 mUnscaledDrawingCache = null
 mUnsetPressedState = null
 mUserPaddingBottom = 29
 mUserPaddingEnd = -2147483648
 mUserPaddingLeft = 10
 mUserPaddingLeftInitial = 10
 mUserPaddingRight = 10
 mUserPaddingRightInitial = 10
 mUserPaddingStart = -2147483648
 mVerticalScrollFactor = 0.0
 mVerticalScrollbarPosition = 0
 mViewFlags = 405028865
 mWindowAttachCount = 1
 shadow$_klass_ = {Class@5076} "class android.support.v7.widget.AppCompatEditText"
 shadow$_monitor_ = -1944738814  


(When I gave some value of email)


email = {AppCompatEditText@5199} "android.support.v7.widget.AppCompatEditText{9041f8b VFED..CL. .F...... 79,242-1001,360 #7f09003d app:id/email}"
 mBackgroundTintHelper = {AppCompatBackgroundHelper@5250} 
 mTextHelper = {AppCompatTextHelperV17@5251} 
 mAllowTransformationLengthChange = false
 mAutoLinkMask = 0
 mBoring = null
 mBreakStrategy = 0
 mBufferType = {TextView$BufferType@5252} "EDITABLE"
 mChangeWatcher = {TextView$ChangeWatcher@5253} 
 mCharWrapper = null
 mCurHintTextColor = 1627389952
 mCurTextColor = -570425344
 mCurrentSpellCheckerLocaleCache = null
 mCursorDrawableRes = 17303397
 mDeferScroll = -1
 mDesiredHeightAtMeasure = 118
 mDeviceProvisionedState = 0
 mDrawables = null
 mEditableFactory = {Editable$Factory@5254} 
 mEditor = {Editor@5255} 
 mEllipsize = null
 mFilters = {InputFilter[0]@5256} 
 mFreezesText = false
 mGravity = 8388627
 mHighlightColor = 1711314568
 mHighlightPaint = {Paint@5257} 
 mHighlightPath = {Path@5258} 
 mHighlightPathBogus = false
 mHint = "Email"
 mHintBoring = {BoringLayout$Metrics@5260} "FontMetricsInt: top=-50 ascent=-44 descent=11 bottom=13 leading=0 width=116"
 mHintLayout = {BoringLayout@5261} 
 mHintTextColor = {ColorStateList@5262} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[16842910, 16842919], []]mColors=[-1979711488, 1627389952]mDefaultColor=1627389952}"
 mHorizontallyScrolling = true
 mHyphenationFrequency = 1
 mIncludePad = true
 mLastLayoutDirection = 0
 mLastScroll = 0
 mLayout = {DynamicLayout@5263} 
 mLinkTextColor = {ColorStateList@5264} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[]]mColors=[-16738680]mDefaultColor=-16738680}"
 mLinksClickable = true
 mListeners = null
 mLocalesChanged = false
 mMarquee = null
 mMarqueeFadeMode = 0
 mMarqueeRepeatLimit = 3
 mMaxMode = 1
 mMaxWidth = 2147483647
 mMaxWidthMode = 2
 mMaximum = 1
 mMinMode = 1
 mMinWidth = 0
 mMinWidthMode = 2
 mMinimum = 1
 mMovement = {ArrowKeyMovementMethod@5265} 
 mOldMaxMode = 1
 mOldMaximum = 1
 mPreDrawListenerDetached = false
 mPreDrawRegistered = false
 mPreventDefaultMovement = false
 mRestartMarquee = false
 mSavedHintLayout = {BoringLayout@5261} 
 mSavedLayout = null
 mSavedMarqueeModeLayout = null
 mScroller = null
 mShadowColor = 0
 mShadowDx = 0.0
 mShadowDy = 0.0
 mShadowRadius = 0.0
 mSingleLine = true
 mSpacingAdd = 0.0
 mSpacingMult = 1.0
 mSpannableFactory = {Spannable$Factory@5266} 
 mTempRect = {Rect@5267} "Rect(374, 305 - 378, 423)"
 mText = {SpannableStringBuilder@5268} "wfm@dm.ssc"
 mTextColor = {ColorStateList@5269} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[973078528, -570425344]mDefaultColor=-570425344}"
 mTextDir = {TextDirectionHeuristics$TextDirectionHeuristicInternal@5270} 
 mTextEditSuggestionContainerLayout = 17367285
 mTextEditSuggestionHighlightStyle = 16974923
 mTextEditSuggestionItemLayout = 17367287
 mTextPaint = {TextPaint@5271} 
 mTextSelectHandleLeftRes = 17303401
 mTextSelectHandleRes = 17303403
 mTextSelectHandleRightRes = 17303405
 mTransformation = {SingleLineTransformationMethod@5272} 
 mTransformed = {ReplacementTransformationMethod$SpannedReplacementCharSequence@5273} "wfm@dm.ssc"
 mUserSetTextScaleX = false
 mAccessibilityCursorPosition = -1
 mAccessibilityDelegate = null
 mAccessibilityTraversalAfterId = -1
 mAccessibilityTraversalBeforeId = -1
 mAccessibilityViewId = -1
 mAnimator = null
 mAttachInfo = {View$AttachInfo@5274} 
 mAttributes = null
 mBackground = {InsetDrawable@5275} 
 mBackgroundRenderNode = {RenderNode@5276} 
 mBackgroundResource = 0
 mBackgroundSizeChanged = false
 mBackgroundTint = null
 mBottom = 360
 mCachingFailed = false
 mClipBounds = null
 mContentDescription = null
 mContext = {LoginActivity@5195} 
 mCurrentAnimation = null
 mDrawableState = {int[4]@5277} 
 mDrawingCache = null
 mDrawingCacheBackgroundColor = 0
 mFloatingTreeObserver = null
 mForegroundInfo = null
 mFrameMetricsObservers = null
 mGhostView = null
 mHasPerformedLongPress = false
 mID = 2131296317
 mIgnoreNextUpEvent = false
 mInContextButtonPress = false
 mInputEventConsistencyVerifier = null
 mKeyedTags = null
 mLabelForId = -1
 mLastIsOpaque = false
 mLayerPaint = null
 mLayerType = 0
 mLayoutInsets = null
 mLayoutParams = {LinearLayout$LayoutParams@5278} 
 mLeft = 79
 mLeftPaddingDefined = false
 mListenerInfo = null
 mLongClickX = NaN
 mLongClickY = NaN
 mMatchIdPredicate = null
 mMatchLabelForPredicate = null
 mMeasureCache = {LongSparseLongArray@5279} "{4611689978387236305=3959959847030}"
 mMeasuredHeight = 118
 mMeasuredWidth = 922
 mMinHeight = 0
 View.mMinWidth = 0
 mNestedScrollingParent = null
 mNextFocusDownId = -1
 mNextFocusForwardId = -1
 mNextFocusLeftId = -1
 mNextFocusRightId = -1
 mNextFocusUpId = -1
 mOldHeightMeasureSpec = 1489
 mOldWidthMeasureSpec = 1073742746
 mOutlineProvider = {ViewOutlineProvider$1@5280} 
 mOverScrollMode = 1
 mOverlay = null
 mPaddingBottom = 29
 mPaddingLeft = 10
 mPaddingRight = 10
 mPaddingTop = 26
 mParent = {LinearLayout@5281} "android.widget.LinearLayout{bd21b35 V.E...... ........ 0,0-1080,1997 #7f090000 app:id/SignIn_Layout}"
 mPendingCheckForLongPress = null
 mPendingCheckForTap = null
 mPerformClick = null
 mPointerIcon = null
 mPrivateFlags = 16812082
 mPrivateFlags2 = 1611867688
 mPrivateFlags3 = 4
 mRecreateDisplayList = false
 mRenderNode = {RenderNode@5282} 
 mResources = {Resources@5234} 
 mRight = 1001
 mRightPaddingDefined = false
 mRunQueue = {HandlerActionQueue@5283} 
 mScrollCache = null
 mScrollIndicatorDrawable = null
 mScrollX = 0
 mScrollY = 0
 mSendViewScrolledAccessibilityEvent = null
 mSendViewStateChangedAccessibilityEvent = null
 mSendingHoverAccessibilityEvents = false
 mStartActivityRequestWho = null
 mStateListAnimator = null
 mSystemUiVisibility = 0
 mTag = null
 mTempNestedScrollConsumed = null
 mTop = 242
 mTouchDelegate = null
 mTouchSlop = 21
 mTransformationInfo = {View$TransformationInfo@5284} 
 mTransientStateCount = 0
 mTransitionName = null
 mUnscaledDrawingCache = null
 mUnsetPressedState = null
 mUserPaddingBottom = 29
 mUserPaddingEnd = -2147483648
 mUserPaddingLeft = 10
 mUserPaddingLeftInitial = 10
 mUserPaddingRight = 10
 mUserPaddingRightInitial = 10
 mUserPaddingStart = -2147483648
 mVerticalScrollFactor = 0.0
 mVerticalScrollbarPosition = 0
 mViewFlags = 405028865
 mWindowAttachCount = 1
 shadow$_klass_ = {Class@5076} "class android.support.v7.widget.AppCompatEditText"
 shadow$_monitor_ = -1996218485  


password = {AppCompatEditText@5200} "android.support.v7.widget.AppCompatEditText{8dff868 VFED..CL. ........ 79,400-1001,518 #7f090075 app:id/password}"
 mBackgroundTintHelper = {AppCompatBackgroundHelper@5308} 
 mTextHelper = {AppCompatTextHelperV17@5309} 
 mAllowTransformationLengthChange = false
 mAutoLinkMask = 0
 mBoring = null
 mBreakStrategy = 0
 mBufferType = {TextView$BufferType@5252} "EDITABLE"
 mChangeWatcher = {TextView$ChangeWatcher@5310} 
 mCharWrapper = null
 mCurHintTextColor = 1627389952
 mCurTextColor = -570425344
 mCurrentSpellCheckerLocaleCache = null
 mCursorDrawableRes = 17303397
 mDeferScroll = -1
 mDesiredHeightAtMeasure = 118
 mDeviceProvisionedState = 0
 mDrawables = null
 mEditableFactory = {Editable$Factory@5254} 
 mEditor = {Editor@5311} 
 mEllipsize = null
 mFilters = {InputFilter[0]@5256} 
 mFreezesText = false
 mGravity = 8388627
 mHighlightColor = 1711314568
 mHighlightPaint = {Paint@5312} 
 mHighlightPath = null
 mHighlightPathBogus = true
 mHint = "Password"
 mHintBoring = {BoringLayout$Metrics@5314} "FontMetricsInt: top=-50 ascent=-44 descent=11 bottom=13 leading=0 width=224"
 mHintLayout = {BoringLayout@5315} 
 mHintTextColor = {ColorStateList@5262} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[16842910, 16842919], []]mColors=[-1979711488, 1627389952]mDefaultColor=1627389952}"
 mHorizontallyScrolling = true
 mHyphenationFrequency = 1
 mIncludePad = true
 mLastLayoutDirection = 0
 mLastScroll = 0
 mLayout = {DynamicLayout@5316} 
 mLinkTextColor = {ColorStateList@5264} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[]]mColors=[-16738680]mDefaultColor=-16738680}"
 mLinksClickable = true
 mListeners = null
 mLocalesChanged = false
 mMarquee = null
 mMarqueeFadeMode = 0
 mMarqueeRepeatLimit = 3
 mMaxMode = 1
 mMaxWidth = 2147483647
 mMaxWidthMode = 2
 mMaximum = 1
 mMinMode = 1
 mMinWidth = 0
 mMinWidthMode = 2
 mMinimum = 1
 mMovement = {ArrowKeyMovementMethod@5265} 
 mOldMaxMode = 1
 mOldMaximum = 1
 mPreDrawListenerDetached = false
 mPreDrawRegistered = false
 mPreventDefaultMovement = false
 mRestartMarquee = false
 mSavedHintLayout = {BoringLayout@5315} 
 mSavedLayout = null
 mSavedMarqueeModeLayout = null
 mScroller = null
 mShadowColor = 0
 mShadowDx = 0.0
 mShadowDy = 0.0
 mShadowRadius = 0.0
 mSingleLine = true
 mSpacingAdd = 0.0
 mSpacingMult = 1.0
 mSpannableFactory = {Spannable$Factory@5266} 
 mTempRect = null
 mText = {SpannableStringBuilder@5317} ""
 mTextColor = {ColorStateList@5269} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[973078528, -570425344]mDefaultColor=-570425344}"
 mTextDir = {TextDirectionHeuristics$TextDirectionHeuristicInternal@5318} 
 mTextEditSuggestionContainerLayout = 17367285
 mTextEditSuggestionHighlightStyle = 16974923
 mTextEditSuggestionItemLayout = 17367287
 mTextPaint = {TextPaint@5319} 
 mTextSelectHandleLeftRes = 17303401
 mTextSelectHandleRes = 17303403
 mTextSelectHandleRightRes = 17303405
 mTransformation = {PasswordTransformationMethod@5320} 
 mTransformed = {PasswordTransformationMethod$PasswordCharSequence@5321} ""
 mUserSetTextScaleX = false
 mAccessibilityCursorPosition = -1
 mAccessibilityDelegate = null
 mAccessibilityTraversalAfterId = -1
 mAccessibilityTraversalBeforeId = -1
 mAccessibilityViewId = -1
 mAnimator = null
 mAttachInfo = {View$AttachInfo@5274} 
 mAttributes = null
 mBackground = {InsetDrawable@5322} 
 mBackgroundRenderNode = {RenderNode@5323} 
 mBackgroundResource = 0
 mBackgroundSizeChanged = false
 mBackgroundTint = null
 mBottom = 518
 mCachingFailed = false
 mClipBounds = null
 mContentDescription = null
 mContext = {LoginActivity@5195} 
 mCurrentAnimation = null
 mDrawableState = {int[3]@5324} 
 mDrawingCache = null
 mDrawingCacheBackgroundColor = 0
 mFloatingTreeObserver = null
 mForegroundInfo = null
 mFrameMetricsObservers = null
 mGhostView = null
 mHasPerformedLongPress = false
 mID = 2131296373
 mIgnoreNextUpEvent = false
 mInContextButtonPress = false
 mInputEventConsistencyVerifier = null
 mKeyedTags = null
 mLabelForId = -1
 mLastIsOpaque = false
 mLayerPaint = null
 mLayerType = 0
 mLayoutInsets = null
 mLayoutParams = {LinearLayout$LayoutParams@5278} 
 mLeft = 79
 mLeftPaddingDefined = false
 mListenerInfo = null
 mLongClickX = NaN
 mLongClickY = NaN
 mMatchIdPredicate = null
 mMatchLabelForPredicate = null
 mMeasureCache = {LongSparseLongArray@5325} "{4611689978387236147=3959959847030}"
 mMeasuredHeight = 118
 mMeasuredWidth = 922
 mMinHeight = 0
 View.mMinWidth = 0
 mNestedScrollingParent = null
 mNextFocusDownId = -1
 mNextFocusForwardId = -1
 mNextFocusLeftId = -1
 mNextFocusRightId = -1
 mNextFocusUpId = -1
 mOldHeightMeasureSpec = 1331
 mOldWidthMeasureSpec = 1073742746
 mOutlineProvider = {ViewOutlineProvider$1@5280} 
 mOverScrollMode = 1
 mOverlay = null
 mPaddingBottom = 29
 mPaddingLeft = 10
 mPaddingRight = 10
 mPaddingTop = 26
 mParent = {LinearLayout@5281} "android.widget.LinearLayout{bd21b35 V.E...... ........ 0,0-1080,1997 #7f090000 app:id/SignIn_Layout}"
 mPendingCheckForLongPress = null
 mPendingCheckForTap = null
 mPerformClick = null
 mPointerIcon = null
 mPrivateFlags = 16812080
 mPrivateFlags2 = 1611867688
 mPrivateFlags3 = 4
 mRecreateDisplayList = false
 mRenderNode = {RenderNode@5326} 
 mResources = {Resources@5234} 
 mRight = 1001
 mRightPaddingDefined = false
 mRunQueue = null
 mScrollCache = null
 mScrollIndicatorDrawable = null
 mScrollX = 0
 mScrollY = 0
 mSendViewScrolledAccessibilityEvent = null
 mSendViewStateChangedAccessibilityEvent = null
 mSendingHoverAccessibilityEvents = false
 mStartActivityRequestWho = null
 mStateListAnimator = null
 mSystemUiVisibility = 0
 mTag = null
 mTempNestedScrollConsumed = null
 mTop = 400
 mTouchDelegate = null
 mTouchSlop = 21
 mTransformationInfo = {View$TransformationInfo@5327} 
 mTransientStateCount = 0
 mTransitionName = null
 mUnscaledDrawingCache = null
 mUnsetPressedState = null
 mUserPaddingBottom = 29
 mUserPaddingEnd = -2147483648
 mUserPaddingLeft = 10
 mUserPaddingLeftInitial = 10
 mUserPaddingRight = 10
 mUserPaddingRightInitial = 10
 mUserPaddingStart = -2147483648
 mVerticalScrollFactor = 0.0
 mVerticalScrollbarPosition = 0
 mViewFlags = 405028865
 mWindowAttachCount = 1
 shadow$_klass_ = {Class@5076} "class android.support.v7.widget.AppCompatEditText"
 shadow$_monitor_ = -1998587800

最佳答案

我已经使用 password.text.toString().isNullOrEmpty() 来达到预期的结果。
不知道为什么 email.text == null 有效,但 password.text == null 无效。欢迎任何建议

关于android - 'when' 语句在 Kotlin for Android 中跳过条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45437075/

相关文章:

java - Recyclerview 从 Picasso 加载缓存的图像非常缓慢

java - android studio 使用或覆盖已弃用的 API

java - 如何暂停和播放音乐播放器

java - Android grpc 失败异常

Android Kotlin AAR - 地点和方式

java - 调用具有相同前缀的不同变量只改变后缀

带有 PhoneGap : InvocationTarget Exception by calling addJavascriptInterface 的安卓应用

android - 每个安卓手机都有 en_US 语言环境吗?

android-studio - Invalidate Caches/Restart在Android Studio中做什么?

android - 当 Dagger 不自动生成组件代码时对 gradle 文件进行故障排除