EditText的setError()崩溃了

时间:2015-12-14 19:16:15

标签: android android-edittext

我正在尝试在setError()上使用EditText方法,但每次崩溃时都会使用此日志:

 12-14 17:07:30.764    2026-2026/com.facta.msmart E/PropertyValuesHolder﹕ Couldn't find no-arg method for property currentBottomLines: java.lang.NoSuchMethodException: getCurrentBottomLines [] 12-14 17:07:30.765    2026-2026/com.facta.msmart E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.facta.msmart, PID: 2026
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
            at com.nineoldandroids.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:533)
            at com.nineoldandroids.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:410)
            at com.nineoldandroids.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:538)
            at com.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:928)
            at com.nineoldandroids.animation.ValueAnimator.start(ValueAnimator.java:951)
            at com.nineoldandroids.animation.ObjectAnimator.start(ObjectAnimator.java:385)
            at com.rengwuxian.materialedittext.MaterialEditText.adjustBottomLines(MaterialEditText.java:827)
            at com.rengwuxian.materialedittext.MaterialEditText.onLayout(MaterialEditText.java:803)
            at android.view.View.layout(View.java:15671)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
            at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1692)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1468)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
            at android.widget.ScrollView.onLayout(ScrollView.java:1502)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1626)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:907)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:493)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
            at android.view.View.layout(View.java:15671)
            at android.view.ViewGroup.layout(ViewGroup.java:5038)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:514)

我通常在片段中调用setError,如下所示:

mEditText.setError("test")

有人能帮助我吗?

1 个答案:

答案 0 :(得分:-1)

我正在使用MaterialEditText的库来重现KitKat中Lollipop的浮动标签属性..因为几个月前AppCompat仍然没有让这个工作..这个问题发生在我试图MaterialEditText上的setError。我将AppCompat更新到最新版本+ TextInputLayout + Android的EditText,我得到了一切正常工作:setKat和Lollipop中的setError方法和浮动标签。