android 解决.XML提示ava.lang.NullPointerException at错误后XML没显示
提示错误:
1 java.lang.NullPointerException 2 Exception details are logged in Window > Show View > Error Log 3 4 java.lang.NullPointerException 5 at com.xxxx.ui.xxxxview.IphoneTreeView.onLayout(IphoneTreeView.java:236) 6 at android.view.View.layout(View.java:14817) 7 at android.view.ViewGroup.layout(ViewGroup.java:4631) 8 at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 9 at android.widget.FrameLayout.onLayout(FrameLayout.java:388) 10 at android.view.View.layout(View.java:14817) 11 at android.view.ViewGroup.layout(ViewGroup.java:4631) 12 ....
意思是提示 指针或对象空,具体列表;
解决方法:点击“IphoneTreeView.java:236”会跳到错误的.JAVA代码中,
对对象或指针进行判断不为NULL再使用。如:
1 int state =0; 2 if (mAdapter != null)//加上判断就可以解决,之前是没有判断引起的 3 state = mAdapter.getTreeHeaderState(groupPos, childPos);