0

the below is the image adapter. I assigned setOnClickListener when I click it , I start a new intent to a new activity, but I want to send this image in this adapter to another activity and set it an image view. my problem is I didnt know how to transfer viewholder.image to bitmap and send it through intent. how to that

    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();
    }
    Listitem item = getItem(position);
    System.out.println("item.getUrl() ");
    System.out.println(item.getUrl());

    holder.imageTitle.setText(item.getId());
    Picasso.
            with(mcontext).
            load(item.getUrl())
            .placeholder(R.drawable.logo)
            .fit()
            .into(holder.imageView);

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

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

            Log.d("OnImageButton", "Clicked");
            Intent intnt  =new Intent(mcontext, SingleViewActivity.class);
            Bitmap imageID=holder.imageView; // error here
            intnt.putExtra("ImageId", imageID);
            mcontext.startActivity(intnt)  ; 

            Toast.makeText(mcontext, "intent",
                    Toast.LENGTH_LONG).show();
        }
    });


    return row;
}

static class ViewHolder {
    TextView imageTitle;
    ImageView imageView;
}
josedlujan
  • 5,357
  • 2
  • 27
  • 49
Moudiz
  • 7,211
  • 22
  • 78
  • 156
  • 1
    See my answer at http://stackoverflow.com/questions/32131605/how-to-move-image-captured-with-the-phone-camera-from-one-activity-to-an-image-v/32132186#32132186 to see if it can help you or not – BNK Nov 03 '15 at 00:13
  • @bnk I did solve this but thanks for recomandation – Moudiz Nov 03 '15 at 05:13

1 Answers1

1

Don't sent the Bitmap. Send the url and use Picasso to retrieve it. The library keeps the Bitmap cached on the disk, so it will not download it again, and loading it from the disk cache will not take long

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • hello man ,.. why its better reading from the cache than sending the image to imageview, what is the difference? and is it enough in `singleviewactivity` to run onlypicasso ? – Moudiz Oct 29 '15 at 20:40
  • 1
    well... Passing the `String` will require less memory than passing the whole bitmap – Blackbelt Oct 29 '15 at 20:44
  • do you still have questions on this topic? – Blackbelt Nov 02 '15 at 21:16