listview滚动崩溃只在android kitkat 4.4上

时间:2014-05-15 07:21:54

标签: android android-listview android-4.4-kitkat

我有一个奇怪的kitkat行为,当我向上和向下滚动listview然后突然应用程序崩溃,但这只发生在kitkat,在该版本下工作正常。

任何想法请帮忙,下面是崩溃报告

05-15 12:49:45.814: E/Surface(22053): dequeueBuffer failed (Invalid argument)
05-15 12:49:45.815: E/ViewRootImpl(22053): Could not lock surface
05-15 12:49:45.815: E/ViewRootImpl(22053): java.lang.IllegalArgumentException
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.Surface.nativeLockCanvas(Native Method)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.Surface.lockCanvas(Surface.java:243)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2466)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.ViewRootImpl.draw(ViewRootImpl.java:2440)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2284)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1914)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1024)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5796)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.Choreographer.doCallbacks(Choreographer.java:574)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.Choreographer.doFrame(Choreographer.java:544)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.os.Handler.handleCallback(Handler.java:733)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.os.Handler.dispatchMessage(Handler.java:95)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.os.Looper.loop(Looper.java:136)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at android.app.ActivityThread.main(ActivityThread.java:5102)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at java.lang.reflect.Method.invokeNative(Native Method)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at java.lang.reflect.Method.invoke(Method.java:515)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-15 12:49:45.815: E/ViewRootImpl(22053):  at dalvik.system.NativeStart.main(Native Method)

这是适配器代码

public class CommonAdapter<T> extends ArrayAdapter<T> {

        Context context;
        int layout;
        List<T> list;
        int position;

        public CommonAdapter(Context context, int textViewResourceId, List<T> list) {
            super(context, textViewResourceId, list);
            this.context = context;
            this.layout = textViewResourceId;
            this.list = list;

        }

        @Override
        public int getCount() {
            return list.size();
        }

        @SuppressWarnings("unchecked")
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            ViewHolder holder = null;
            if (convertView == null) {
                LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = vi.inflate(layout, null);
                holder = new ViewHolder();
                holder.parentRelativeLayout = (RelativeLayout) convertView.findViewById(R.id.item_parent);
                holder.item_tittle = (TextView) convertView.findViewById(R.id.tv_item_tittle);
                holder.item_discount = (TextView) convertView.findViewById(R.id.discount_txt);
                holder.discountLayout = (LinearLayout) convertView.findViewById(R.id.discount_layout);
                holder.lined_price = (LinedTextView) convertView.findViewById(R.id.lined_price);
                holder.starting_price = (TextView) convertView.findViewById(R.id.tv_starting_price);
                holder.img = (ImageView) convertView.findViewById(R.id.contentimage);
                holder.buy_button = (Button) convertView.findViewById(R.id.bt_buy_now);

                convertView.setTag(holder);

            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            holder.buy_button.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    CommonAdapter.this.position = position;
                    handler.sendEmptyMessage(Constants.SHOW_PROGRESS_DIALOG);
                    new Thread(fetchProductDetail).start();

                }
            });
            ContentItem contentItem = (ContentItem) list.get(position);
            try {
                holder.item_tittle.setText(contentItem.getTitle_item().replace("&amp;", "&"));
            }
            catch (Exception e) {
                //title is null
                Crashlytics.logException(e);
                holder.item_tittle.setText("Not Available");
                if(contentItem!=null ){

                }
                Crashlytics.log("Item title not available for "+contentItem.getId_item());

            }

            holder.lined_price.setText(contentItem.getMarketing_price_formatted());
            holder.starting_price.setText(contentItem.getStarting_price_formatted());

            holder.parentRelativeLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    CommonAdapter.this.position = position;
                    handler.sendEmptyMessage(Constants.SHOW_PROGRESS_DIALOG);
                    new Thread(fetchProductDetail).start();

                }
            });

            String imPath = Utility.getImageRevisedPath(contentItem.getImages().get(0), "L");
            holder.img.setTag(imPath);
            imageLoader.displayImage(imPath, holder.img);
            return convertView;
        }

        private class ViewHolder {
            TextView starting_price;
            LinedTextView lined_price;
            TextView item_tittle, item_discount;
            ImageView img;
            Button buy_button;
            LinearLayout discountLayout;
            RelativeLayout parentRelativeLayout;
        }

0 个答案:

没有答案