在毕加索中,向上或向下滚动时始终显示图像背景(持有者)

时间:2015-12-23 17:07:54

标签: android picasso

我在毕加索遇到问题,当我向上或向下滚动图像再次加载以便再次显示背景时,此question描述了我的问题,但应用用户Taha的答案对我没有用,而现在我不能使用别的东西然后毕加索。

enter image description here

这是我的代码

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        System.out.println("entering adapter1");

        View row = convertView;
      final  ViewHolder holder;


        if (row == null) {
            LayoutInflater inflater = LayoutInflater.from(mcontext);
            row = inflater.inflate(layoutResourceId, parent, false);
            holder = new ViewHolder();
            holder.imageTitle = (TextView) row.findViewById(R.id.text);
            holder.imageView = (ImageView) row.findViewById(R.id.imageView);
            row.setTag(holder);
        } else {
            holder = (ViewHolder) row.getTag();
        }
        final Listitem item = getItem(position);
        System.out.println("item.getUrl() ");
        System.out.println(item.getUrl());
        Picasso.with(mcontext).setIndicatorsEnabled(true);
        holder.imageTitle.setText(item.getId());
        Picasso.
                with(mcontext).
                load(item.getUrl())
                .placeholder(R.drawable.logo)
                .fit()
                .noFade()
                .into(holder.imageView)
                .memoryCache(new LruCache(cacheSize))
        ;

        holder.imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                ArrayList<Listitem> personArrayList = new ArrayList<>();
                personArrayList.add(new Listitem(item.getId(), item.getUrl()));

                Intent intent = new Intent(mcontext,SingleViewActivity.class);
                intent.putExtra("Person_List", personArrayList);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mcontext.startActivity(intent);

                Log.d("OnImageButton", "Clicked");
            }
        });


        return row;
    }

    static class ViewHolder {
        TextView imageTitle;
        ImageView imageView;
    }

编辑错误

enter image description here

1 个答案:

答案 0 :(得分:0)

int cacheSize = 4 * 1024 * 1024; // 4MiB    
Picasso myNewPicasso = new Picasso.Builder(context).memoryCache(new LruCache(cacheSize)).build();  

    myNewPicasso.with(mcontext)
                .load(item.getUrl())
                .placeholder(R.drawable.logo)
                .fit()
                .noFade()
                .into(holder.imageView);