在android中重复加载listview时出现Stackoverflow错误

时间:2015-01-15 14:42:49

标签: android android-layout

发生了什么:重复加载此ListView时,我收到如下日志错误(我计算了10次)。如何解决这个问题?

我在listview的适配器中使用这些代码

    viewHolder.btnPhoneId.setTag(R.string.tag_phoneNo,_searchModel.get(position).getPhno());


    if (_searchModel.get(position).getProfleImage() == null || _searchModel.get(position).getProfleImage().equals("") || _searchModel.get(position).getProfleImage().length()==0) {
        //imgPerPicOneId.setImageDrawable(getResources().getDrawable(R.drawable.no_profile_image));
        Picasso.with(context)
        .load(R.drawable.ic_launcher)
        .transform(new RoundedTransformation(50, 4))
        .resize(100, 100)
        .centerCrop().into(viewHolder.profileImage);
    }else{
        String finalImg=context.getResources().getString(R.string.image_api)+_searchModel.get(position).getProfleImage().replace("Windhyaapp/","");
        Picasso.with(context)
        .load(finalImg)
        .transform(new RoundedTransformation(50, 4))
        .resize(100, 100)
        .centerCrop().into(viewHolder.profileImage);
    }


    //For Favorite icon
    if(_searchModel.get(position).getFav()==false){
        viewHolder.btnFavId.setBackgroundResource(R.drawable.heart_grey);
        viewHolder.btnFavId.setTag("heart_grey");
    }else{
        viewHolder.btnFavId.setBackgroundResource(R.drawable.heart_blue);
        viewHolder.btnFavId.setTag("heart_blue");
    }

    //For Phone icon
    if(_searchModel.get(position).getBid()==false){
        viewHolder.btnPhoneId.setVisibility(View.INVISIBLE);
        viewHolder.btnPhoneId.setTag("INVISIBLE");
    }else{
        viewHolder.btnPhoneId.setVisibility(View.VISIBLE);
        viewHolder.btnPhoneId.setTag("VISIBLE");
    }

    viewHolder.btnFavId.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            try {
                String favTag=viewHolder.btnFavId.getTag().toString();
                String phnoTag=viewHolder.btnPhoneId.getTag().toString();
                String serviceProviderId=viewHolder.serviceProviderId.getTag().toString();

                if(favTag.equalsIgnoreCase("heart_grey")){
                    viewHolder.btnFavId.setBackgroundResource(R.drawable.heart_blue);
                    viewHolder.btnFavId.setTag("heart_blue");

                    prepJSON("heart_blue",serviceProviderId);
                    //new LongOperationFavUnfav().execute("");
                    LongOperationFavUnfav();

                }else{
                    viewHolder.btnFavId.setBackgroundResource(R.drawable.heart_grey);
                    viewHolder.btnFavId.setTag("heart_grey");
                    prepJSON("heart_grey",serviceProviderId);
                    //new LongOperationFavUnfav().execute("");
                    LongOperationFavUnfav();
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

日志:

01-15 20:06:49.929: E/AndroidRuntime(29661): FATAL EXCEPTION: main
01-15 20:06:49.929: E/AndroidRuntime(29661): Process: com.windhyaworks, PID: 29661
01-15 20:06:49.929: E/AndroidRuntime(29661): java.lang.StackOverflowError
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.graphics.Bitmap.isPremultiplied(Bitmap.java:1056)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1086)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:844)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:490)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at com.squareup.picasso.PicassoDrawable.draw(PicassoDrawable.java:96)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.widget.ImageView.onDraw(ImageView.java:1032)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14508)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13405)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13400)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13400)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.widget.ListView.drawChild(ListView.java:3363)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.widget.AbsListView.dispatchDraw(AbsListView.java:2465)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.widget.ListView.dispatchDraw(ListView.java:3358)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14511)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.widget.AbsListView.draw(AbsListView.java:3824)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13405)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13400)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13400)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14511)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13405)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1057)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13400)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14511)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.widget.FrameLayout.draw(FrameLayout.java:472)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13405)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14511)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.support.v7.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:509)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13405)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.drawChild(ViewGroup.java:3105)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2942)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13400)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.getDisplayList(View.java:13447)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.view.View.draw(View.java:14225)
01-15 20:06:49.929: E/AndroidRuntime(29661):    at android.vie

0 个答案:

没有答案