Android NullPointerException at android.text.BoringLayout.isBoring

最近遇到个很奇怪的问题,如题,下面是详细报错信息:

E/AndroidRuntime: FATAL EXCEPTION: main
                  java.lang.NullPointerException
                      at android.text.BoringLayout.isBoring(BoringLayout.java:260)
                      at android.widget.TextView.onMeasure(TextView.java:6158)
                      at android.view.View.measure(View.java:15518)
                      at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
                      at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
                      at android.view.View.measure(View.java:15518)
                      at android.widget.ListView.setupChild(ListView.java:1909)
                      at android.widget.ListView.makeAndAddView(ListView.java:1834)
                      at android.widget.ListView.fillSpecific(ListView.java:1320)
                      at android.widget.ListView.layoutChildren(ListView.java:1642)
                      at android.widget.AbsListView.onLayout(AbsListView.java:1994)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
                      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
                      at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
                      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
                      at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
                      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
                      at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                      at android.view.View.layout(View.java:14008)
                      at android.view.ViewGroup.layout(ViewGroup.java:4373)
                      at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
                      at android.view.Choreographer.doCallbacks(Choreographer.java:562)
                      at android.view.Choreographer.doFrame(Choreographer.java:532)
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
                      at android.os.Handler.handleCallback(Handler.java:725)
                      at android.os.Handler.dispatchMessage(Handler.java:92)
                      at android.os.Looper.loop(Looper.java:137)
                      at android.app.ActivityThread.main(ActivityThread.java:5041)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:511)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                      at dalvik.system.NativeStart.main(Native Method)


经过排查,是因为项目中用了一个继承自 TextView 的自定义控件,在 setText 方法里面,某些情况直接 return 掉了,然后导致的异常。当重写了 setText 方法的时候,如果调用它,它必须被设值,不能中途强行中断。



http://stackoverflow.com/questions/18214450/nullpointerexception-at-boringlayout-isboring-is-anything-but-boring

你可能感兴趣的:(Android随记,android)