11-25 16:09:10.965 22791-22823/myapplication.com.myblue E/HAL: hw_get_module_by_class: lib loaded: /system/lib/hw/gralloc.msm8909.so 11-25 16:09:24.875 22791-22791/myapplication.com.myblue E/ywq: android.bluetooth.device.action.FOUND 11-25 16:09:24.895 22791-22791/myapplication.com.myblue E/AndroidRuntime: FATAL EXCEPTION: main Process: myapplication.com.myblue, PID: 22791 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference at android.widget.AbsListView.obtainView(AbsListView.java:2385) at android.widget.ListView.makeAndAddView(ListView.java:1868) at android.widget.ListView.fillDown(ListView.java:702) at android.widget.ListView.fillFromTop(ListView.java:763) at android.widget.ListView.layoutChildren(ListView.java:1663) at android.widget.AbsListView.onLayout(AbsListView.java:2169) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1734) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1588) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1734) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1588) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1734) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1588) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2153) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1907) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1105) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6204) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799) at android.view.Choreographer.doCallbacks(Choreographer.java:612) at android.view.Choreographer.doFrame(Choreographer.java:581) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:785) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5593) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:967) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) 11-25 16:09:25.375 24146-24146/myapplication.com.myblue E/HAL: hw_get_module_by_class: lib loaded: /system/lib/hw/gralloc.msm8909.so 11-25 16:09:25.505 24146-24174/myapplication.com.myblue E/HAL: hw_get_module_by_class: lib loaded: /system/lib/hw/gralloc.msm8909.so 11-25 16:09:25.505 24146-24174/myapplication.com.myblue E/HAL: hw_get_module_by_class: lib loaded: /system/lib/hw/gralloc.msm8909.so 11-25 16:09:27.235 24146-24174/myapplication.com.myblue E/HAL: hw_get_module_by_class: lib loaded: /system/lib/hw/gralloc.msm8909.so 11-25 16:09:28.225 24146-24146/myapplication.com.myblue E/ywq: android.bluetooth.adapter.action.DISCOVERY_FINISHED 11-25 16:10:54.245 24146-24146/myapplication.com.myblue E/ywq: android.bluetooth.device.action.FOUND 11-25 16:10:54.255 24146-24146/myapplication.com.myblue E/AndroidRuntime: FATAL EXCEPTION: main Process: myapplication.com.myblue, PID: 24146 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference at android.widget.AbsListView.obtainView(AbsListView.java:2385) at android.widget.ListView.makeAndAddView(ListView.java:1868) at android.widget.ListView.fillDown(ListView.java:702) at android.widget.ListView.fillFromTop(ListView.java:763) at android.widget.ListView.layoutChildren(ListView.java:1663) at android.widget.AbsListView.onLayout(AbsListView.java:2169) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1734) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1588) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1734) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1588) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1734) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1588) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15743) at android.view.ViewGroup.layout(ViewGroup.java:5051) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2153) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1907) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1105) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6204) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799) at android.view.Choreographer.doCallbacks(Choreographer.java:612) at android.view.Choreographer.doFrame(Choreographer.java:581) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:785) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5593) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:967) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
1.
对应的Adapter的getView方法返回为空,出现的这个空指针现象。
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView==null){ convertView= LayoutInflater.from(context).inflate(R.layout.searchitem_layout, null); holder=new ViewHolder(); holder.textViewl=(TextView) convertView.findViewById(R.id.textView_item); convertView.setTag(holder); }else{ holder=(ViewHolder) convertView.getTag(); } String s=datas.get(position); holder.textViewl.setText("MAC:"+s); return convertView; }