2017-08-01 51 views
1

我一直在使用kotlin開發android工作室金絲雀5上的應用程序。我正在使用when語句來驗證註冊表單是否有效。'當'語句跳過Android Kotlin中的條件

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支持處於beta版還是其他原因?

更新:由於JK Ly的建議,以下是電子郵件地址和密碼的值:如果沒有提供任何參數when被用作替代的if-else if 一切

(When I kept email empty) 

email = {[email protected]} "android.support.v7.widget.AppCompatEditText{c15a402 VFED..CL. .F...... 79,242-1001,360 #7f09003d app:id/email}" 
mBackgroundTintHelper = {[email protected]} 
mTextHelper = {[email protected]} 
mAllowTransformationLengthChange = false 
mAutoLinkMask = 0 
mBoring = null 
mBreakStrategy = 0 
mBufferType = {[email protected]} "EDITABLE" 
mChangeWatcher = {[email protected]} 
mCharWrapper = null 
mCurHintTextColor = 1627389952 
mCurTextColor = -570425344 
mCurrentSpellCheckerLocaleCache = null 
mCursorDrawableRes = 17303397 
mDeferScroll = -1 
mDesiredHeightAtMeasure = 118 
mDeviceProvisionedState = 0 
mDrawables = null 
mEditableFactory = {[email protected]} 
mEditor = {[email protected]} 
mEllipsize = null 
mFilters = {InputFilter[0]@5249} 
mFreezesText = false 
mGravity = 8388627 
mHighlightColor = 1711314568 
mHighlightPaint = {[email protected]} 
mHighlightPath = {[email protected]} 
mHighlightPathBogus = false 
mHint = "Email" 
mHintBoring = {[email protected]} "FontMetricsInt: top=-50 ascent=-44 descent=11 bottom=13 leading=0 width=116" 
mHintLayout = {[email protected]} 
mHintTextColor = {[email protected]} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[16842910, 16842919], []]mColors=[-1979711488, 1627389952]mDefaultColor=1627389952}" 
mHorizontallyScrolling = true 
mHyphenationFrequency = 1 
mIncludePad = true 
mLastLayoutDirection = 0 
mLastScroll = 0 
mLayout = {[email protected]} 
mLinkTextColor = {[email protected]} "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 = {[email protected]} 
mOldMaxMode = 1 
mOldMaximum = 1 
mPreDrawListenerDetached = false 
mPreDrawRegistered = false 
mPreventDefaultMovement = false 
mRestartMarquee = false 
mSavedHintLayout = {[email protected]} 
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 = {[email protected]} 
mTempRect = {[email protected]} "Rect(87, 305 - 91, 423)" 
mText = {[email protected]} "" 
    mFilters = {InputFilter[1]@5289} 
    mGapLength = 10 
    mGapStart = 0 
    mIndexOfSpan = {[email protected]} 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_ = {[email protected]} "class android.text.SpannableStringBuilder" 
    shadow$_monitor_ = -2077412599 
mTextColor = {[email protected]} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[973078528, -570425344]mDefaultColor=-570425344}" 
mTextDir = {[email protected]} 
mTextEditSuggestionContainerLayout = 17367285 
mTextEditSuggestionHighlightStyle = 16974923 
mTextEditSuggestionItemLayout = 17367287 
mTextPaint = {[email protected]} 
mTextSelectHandleLeftRes = 17303401 
mTextSelectHandleRes = 17303403 
mTextSelectHandleRightRes = 17303405 
mTransformation = {[email protected]} 
mTransformed = {[email protected]266} "" 
mUserSetTextScaleX = false 
mAccessibilityCursorPosition = -1 
mAccessibilityDelegate = null 
mAccessibilityTraversalAfterId = -1 
mAccessibilityTraversalBeforeId = -1 
mAccessibilityViewId = -1 
mAnimator = null 
mAttachInfo = {[email protected]} 
mAttributes = null 
mBackground = {[email protected]} 
mBackgroundRenderNode = {[email protected]} 
mBackgroundResource = 0 
mBackgroundSizeChanged = false 
mBackgroundTint = null 
mBottom = 360 
mCachingFailed = false 
mClipBounds = null 
mContentDescription = null 
mContext = {[email protected]} 
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 = {[email protected]} 
mLeft = 79 
mLeftPaddingDefined = false 
mListenerInfo = null 
mLongClickX = NaN 
mLongClickY = NaN 
mMatchIdPredicate = null 
mMatchLabelForPredicate = null 
mMeasureCache = {[email protected]} "{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 = {[email protected]} 
mOverScrollMode = 1 
mOverlay = null 
mPaddingBottom = 29 
mPaddingLeft = 10 
mPaddingRight = 10 
mPaddingTop = 26 
mParent = {[email protected]} "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 = {[email protected]} 
mResources = {[email protected]} 
mRight = 1001 
mRightPaddingDefined = false 
mRunQueue = {[email protected]} 
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 = {[email protected]} 
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_ = {[email protected]} "class android.support.v7.widget.AppCompatEditText" 
shadow$_monitor_ = -1944738814 


(When I gave some value of email) 


email = {[email protected]} "android.support.v7.widget.AppCompatEditText{9041f8b VFED..CL. .F...... 79,242-1001,360 #7f09003d app:id/email}" 
mBackgroundTintHelper = {[email protected]} 
mTextHelper = {[email protected]} 
mAllowTransformationLengthChange = false 
mAutoLinkMask = 0 
mBoring = null 
mBreakStrategy = 0 
mBufferType = {[email protected]} "EDITABLE" 
mChangeWatcher = {[email protected]} 
mCharWrapper = null 
mCurHintTextColor = 1627389952 
mCurTextColor = -570425344 
mCurrentSpellCheckerLocaleCache = null 
mCursorDrawableRes = 17303397 
mDeferScroll = -1 
mDesiredHeightAtMeasure = 118 
mDeviceProvisionedState = 0 
mDrawables = null 
mEditableFactory = {[email protected]} 
mEditor = {[email protected]} 
mEllipsize = null 
mFilters = {InputFilter[0]@5256} 
mFreezesText = false 
mGravity = 8388627 
mHighlightColor = 1711314568 
mHighlightPaint = {[email protected]} 
mHighlightPath = {[email protected]} 
mHighlightPathBogus = false 
mHint = "Email" 
mHintBoring = {[email protected]} "FontMetricsInt: top=-50 ascent=-44 descent=11 bottom=13 leading=0 width=116" 
mHintLayout = {[email protected]} 
mHintTextColor = {[email protected]} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[16842910, 16842919], []]mColors=[-1979711488, 1627389952]mDefaultColor=1627389952}" 
mHorizontallyScrolling = true 
mHyphenationFrequency = 1 
mIncludePad = true 
mLastLayoutDirection = 0 
mLastScroll = 0 
mLayout = {[email protected]} 
mLinkTextColor = {[email protected]} "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 = {[email protected]} 
mOldMaxMode = 1 
mOldMaximum = 1 
mPreDrawListenerDetached = false 
mPreDrawRegistered = false 
mPreventDefaultMovement = false 
mRestartMarquee = false 
mSavedHintLayout = {[email protected]} 
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 = {[email protected]} 
mTempRect = {[email protected]} "Rect(374, 305 - 378, 423)" 
mText = {[email protected]} "[email protected]" 
mTextColor = {[email protected]} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[973078528, -570425344]mDefaultColor=-570425344}" 
mTextDir = {[email protected]} 
mTextEditSuggestionContainerLayout = 17367285 
mTextEditSuggestionHighlightStyle = 16974923 
mTextEditSuggestionItemLayout = 17367287 
mTextPaint = {[email protected]} 
mTextSelectHandleLeftRes = 17303401 
mTextSelectHandleRes = 17303403 
mTextSelectHandleRightRes = 17303405 
mTransformation = {[email protected]} 
mTransformed = {[email protected]273} "[email protected]" 
mUserSetTextScaleX = false 
mAccessibilityCursorPosition = -1 
mAccessibilityDelegate = null 
mAccessibilityTraversalAfterId = -1 
mAccessibilityTraversalBeforeId = -1 
mAccessibilityViewId = -1 
mAnimator = null 
mAttachInfo = {[email protected]} 
mAttributes = null 
mBackground = {[email protected]} 
mBackgroundRenderNode = {[email protected]76} 
mBackgroundResource = 0 
mBackgroundSizeChanged = false 
mBackgroundTint = null 
mBottom = 360 
mCachingFailed = false 
mClipBounds = null 
mContentDescription = null 
mContext = {[email protected]} 
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 = {[email protected]} 
mLeft = 79 
mLeftPaddingDefined = false 
mListenerInfo = null 
mLongClickX = NaN 
mLongClickY = NaN 
mMatchIdPredicate = null 
mMatchLabelForPredicate = null 
mMeasureCache = {[email protected]} "{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 = {[email protected]} 
mOverScrollMode = 1 
mOverlay = null 
mPaddingBottom = 29 
mPaddingLeft = 10 
mPaddingRight = 10 
mPaddingTop = 26 
mParent = {[email protected]} "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 = {[email protected]} 
mResources = {[email protected]} 
mRight = 1001 
mRightPaddingDefined = false 
mRunQueue = {[email protected]} 
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 = {[email protected]} 
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_ = {[email protected]} "class android.support.v7.widget.AppCompatEditText" 
shadow$_monitor_ = -1996218485 


password = {[email protected]} "android.support.v7.widget.AppCompatEditText{8dff868 VFED..CL. ........ 79,400-1001,518 #7f090075 app:id/password}" 
mBackgroundTintHelper = {[email protected]} 
mTextHelper = {[email protected]} 
mAllowTransformationLengthChange = false 
mAutoLinkMask = 0 
mBoring = null 
mBreakStrategy = 0 
mBufferType = {[email protected]} "EDITABLE" 
mChangeWatcher = {[email protected]} 
mCharWrapper = null 
mCurHintTextColor = 1627389952 
mCurTextColor = -570425344 
mCurrentSpellCheckerLocaleCache = null 
mCursorDrawableRes = 17303397 
mDeferScroll = -1 
mDesiredHeightAtMeasure = 118 
mDeviceProvisionedState = 0 
mDrawables = null 
mEditableFactory = {[email protected]} 
mEditor = {[email protected]} 
mEllipsize = null 
mFilters = {InputFilter[0]@5256} 
mFreezesText = false 
mGravity = 8388627 
mHighlightColor = 1711314568 
mHighlightPaint = {[email protected]} 
mHighlightPath = null 
mHighlightPathBogus = true 
mHint = "Password" 
mHintBoring = {[email protected]} "FontMetricsInt: top=-50 ascent=-44 descent=11 bottom=13 leading=0 width=224" 
mHintLayout = {[email protected]} 
mHintTextColor = {Color[email protected]} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[16842910, 16842919], []]mColors=[-1979711488, 1627389952]mDefaultColor=1627389952}" 
mHorizontallyScrolling = true 
mHyphenationFrequency = 1 
mIncludePad = true 
mLastLayoutDirection = 0 
mLastScroll = 0 
mLayout = {[email protected]} 
mLinkTextColor = {[email protected]} "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 = {[email protected]} 
mOldMaxMode = 1 
mOldMaximum = 1 
mPreDrawListenerDetached = false 
mPreDrawRegistered = false 
mPreventDefaultMovement = false 
mRestartMarquee = false 
mSavedHintLayout = {[email protected]} 
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 = {[email protected]} 
mTempRect = null 
mText = {[email protected]} "" 
mTextColor = {[email protected]} "ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[973078528, -570425344]mDefaultColor=-570425344}" 
mTextDir = {[email protected]} 
mTextEditSuggestionContainerLayout = 17367285 
mTextEditSuggestionHighlightStyle = 16974923 
mTextEditSuggestionItemLayout = 17367287 
mTextPaint = {[email protected]} 
mTextSelectHandleLeftRes = 17303401 
mTextSelectHandleRes = 17303403 
mTextSelectHandleRightRes = 17303405 
mTransformation = {[email protected]} 
mTransformed = {[email protected]} "" 
mUserSetTextScaleX = false 
mAccessibilityCursorPosition = -1 
mAccessibilityDelegate = null 
mAccessibilityTraversalAfterId = -1 
mAccessibilityTraversalBeforeId = -1 
mAccessibilityViewId = -1 
mAnimator = null 
mAttachInfo = {[email protected]} 
mAttributes = null 
mBackground = {[email protected]} 
mBackgroundRenderNode = {[email protected]} 
mBackgroundResource = 0 
mBackgroundSizeChanged = false 
mBackgroundTint = null 
mBottom = 518 
mCachingFailed = false 
mClipBounds = null 
mContentDescription = null 
mContext = {[email protected]} 
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 = {[email protected]} 
mLeft = 79 
mLeftPaddingDefined = false 
mListenerInfo = null 
mLongClickX = NaN 
mLongClickY = NaN 
mMatchIdPredicate = null 
mMatchLabelForPredicate = null 
mMeasureCache = {[email protected]} "{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 = {[email protected]} 
mOverScrollMode = 1 
mOverlay = null 
mPaddingBottom = 29 
mPaddingLeft = 10 
mPaddingRight = 10 
mPaddingTop = 26 
mParent = {[email protected]} "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 = {[email protected]} 
mResources = {[email protected]} 
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 = {[email protected]} 
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_ = {[email protected]} "class android.support.v7.widget.AppCompatEditText" 
shadow$_monitor_ = -1998587800 
+0

你在密碼行'password.text == null - > password.error =「Enter Password!」''上得到錯誤信息嗎?如果是這樣,那究竟是什麼? –

+0

不,我沒有收到錯誤。即使當我將密碼字段保留爲空時,它仍不會引起所需的錯誤,即「密碼無效!」 –

+0

「email」和「password」的類型是什麼? – BakaWaii

回答

1

我已經使用password.text.toString().isNullOrEmpty()達到預期的結果。
不知道爲什麼email.text == null有效,但password.text == null沒有。任何建議歡迎

0

工作正常。你得到一個有效的陳述,然後出when Kotlin When Expression

+0

不,我知道。我的意思是我給的電子郵件,但有意留下密碼,但我仍然沒有得到一個錯誤信息 –

+0

所以'password.text == null'不爲空)嘗試使用調試器或日誌並檢查'密碼「變量。有一些錯誤 –

+0

我一直在努力做到這一點。我的問題是,同一行在使用名爲email的編輯文本上使用時效果很好,但在使用名爲password的編輯文本時失敗。我如何使密碼字段爲空時顯示錯誤 –