这可能吗?我的主要活动是
routeListView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String route = values[position];
//for loop to increment through each route list item
int i;
for (i=0; i < values.length;i++)
{
int imageId = (int) image.getResourceId(i, -1);
if (route.equals(values[i]))
{
Intent intent = new Intent(view.getContext(), RouteDetails.class);
intent.putExtra("route", routeDetail[i]);
intent.putExtra("imageResourceId", imageId);
startActivity(intent);
}
}
}
}
现在我将它传递给RouteDetails.class但我也希望将相同的图像传递给FullScreenImage.class。我希望打开路径详细信息活动,但不要打开FullScreenImage活动。然后可以从RouteDetails.class打开FullScreenImage.class活动有没有一种简单的方法来实现这个目的?
答案 0 :(得分:0)
Pscudeo code:-- yes posssible .
you can send it through intent to intent following like that or
else if you have URL you can send that as a string .
Send from Acitivity:---
Intent _intent = new Intent(this, newscreen.class);
Bitmap _bitmap; // your bitmap
ByteArrayOutputStream _bs = new ByteArrayOutputStream();
_bitmap.compress(Bitmap.CompressFormat.PNG, 50, _bs);
i.putExtra("byteArray", _bs.toByteArray());
startActivity(i);
Receive from Acitivity:--
if(getIntent().hasExtra("byteArray")) {
ImageView _imv= new ImageView(this);
Bitmap _bitmap = BitmapFactory.decodeByteArray(
getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length);
_imv.setImageBitmap(_bitmap);
}