简体   繁体   中英

How to send imageview with intent?

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;
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM