今天上午解决的Bug,一上午的时间;
log:
11-01 14:49:14.826: E/InputEventReceiver(30810): Exception dispatching input event. 11-01 14:49:14.850: E/AndroidRuntime(30810): FATAL EXCEPTION: main 11-01 14:49:14.850: E/AndroidRuntime(30810): java.lang.NullPointerException 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.AbsListView.obtainView(AbsListView.java:2348) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.ListView.makeAndAddView(ListView.java:1845) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.ListView.fillDown(ListView.java:678) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.ListView.fillGap(ListView.java:642) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5602) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3346) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.widget.AbsListView.onTouchEvent(AbsListView.java:3699) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.hades.newstyle.customviews.XListView.onTouchEvent(XListView.java:369) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.View.dispatchTouchEvent(View.java:7347) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2352) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2049) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.hades.newstyle.customviews.XListView.dispatchTouchEvent(XListView.java:303) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2358) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2063) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2064) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1513) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.app.Activity.dispatchTouchEvent(Activity.java:2510) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2012) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.View.dispatchPointerEvent(View.java:7527) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3682) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3610) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4862) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4822) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4974) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4942) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4996) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.Choreographer.doCallbacks(Choreographer.java:579) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.Choreographer.doFrame(Choreographer.java:546) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.os.Handler.handleCallback(Handler.java:725) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.os.Handler.dispatchMessage(Handler.java:92) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.os.Looper.loop(Looper.java:153) 11-01 14:49:14.850: E/AndroidRuntime(30810): at android.app.ActivityThread.main(ActivityThread.java:5326) 11-01 14:49:14.850: E/AndroidRuntime(30810): at java.lang.reflect.Method.invokeNative(Native Method) 11-01 14:49:14.850: E/AndroidRuntime(30810): at java.lang.reflect.Method.invoke(Method.java:511) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:848) 11-01 14:49:14.850: E/AndroidRuntime(30810): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615) 11-01 14:49:14.850: E/AndroidRuntime(30810): at dalvik.system.NativeStart.main(Native Method)
跑的时候。APP一 滑动 就自动崩掉。
开始的时候:一直以为是事件分发的问题,Debug 了 好久也没有找到Exception dispatching input event. 中的 java.lang.NullPointerException,在哪里! 找了一上午 也没有头绪。
之后检查,ListView 适配器中的GetView() 方法的时候,发现,convertView
没有给view 赋值,而且返回的是 view.
解决方案:
View view = convertView;
Code:
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO 需要处理新款详情的 ListView布局 Log.i("love", "---getCount() size="+this.getCount()); // View view = convertView; if(view == null) { view = inflater.inflate(R.layout.fragment_new_fashtion_list_item, parent, false); } if(view != null) { ViewHolder holder = (ViewHolder)view.getTag(); if(holder == null) { holder = new ViewHolder(); holder.newImageView = (ImageView) view.findViewById(R.id.new_fashtion_item_image); holder.newTitleView = (TextView) view.findViewById(R.id.new_fashtion_item_title); holder.newShareBtn = (RadioButton) view.findViewById(R.id.new_fashtion_share_btn); holder.newCollectionBtn = (RadioButton) view.findViewById(R.id.new_fashtion_collection_btn); holder.newPriceBtn = (RadioButton) view.findViewById(R.id.new_fashtion_price_btn); view.setTag(holder); } // 获取当前的数据实体。 NewStyleItemEntity entity = (NewStyleItemEntity)newStyleLists.get(position); Log.i("love", "---position="+position); Log.i("love", "---entity= "+newStyleLists.get(position).getPrice()); holder.newTitleView.setText(newStyleLists.get(position).getTitle()); holder.newPriceBtn.append(newStyleLists.get(position).getPrice()); //图片的下载: } return view; }
Exception dispatching input event. use XlistView
原文地址:http://blog.csdn.net/love_javc_you/article/details/40680701