以下是图像适配器。当我点击它时,我分配了setOnClickListener
,我开始了对新活动的新意图,但我想将此图像中的此图像发送到另一个活动并将其设置为图像视图。我的问题是我不知道如何将viewholder.image
转移到位图并通过意图发送它。怎么样呢
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;
}
答案 0 :(得分:1)
请勿发送Bitmap
。发送网址并使用毕加索来检索它。该库将Bitmap缓存在磁盘上,因此不会再次下载,并且从磁盘缓存加载它不会花费很长时间