这是我在活动1中的代码:
ImageView imgg=(ImageView)findViewById(R.id.iv_flag);
Bitmap mImage1 = BitmapFactory.decodeResource
(imgg.getResources),R.id.iv_flag);
imgg.setImageBitmap(mImage1);
String pid = ((TextView) view.findViewById(R.id.tv_country)).getText()
.toString();
String pid2 = ((TextView) view.findViewById(R.id.tv_country_details)).getText()
.toString();
String pid3 = ((ImageView) view.findViewById(R.id.iv_flag))
.toString();
Intent i = new Intent(NewsPage.this,
NewsPageDetails.class);
// //i.setClass(Cafe.this,cafelistselected.class);
i.putExtra("newspage", pid);
i.putExtra("newspages", pid2);
i.putExtra("images", pid3); // this is the string which contain the image
startActivity(i);
这是我在活动2中的代码:
public class NewsPageDetails extends Activity{
String hospitalpress;
String hospitalpress2;
String hospitalpress3;
TextView textmain;
TextView textmain2;
ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.newspagedetails);
textmain=(TextView)findViewById(R.id.textmainss);
textmain2=(TextView)findViewById(R.id.textonee);
image=(ImageView)findViewById(R.id.imgview);
Intent i = getIntent();
hospitalpress = i.getExtras().getString("newspage");
hospitalpress2 = i.getExtras().getString("newspages");
int hodddddspitalpress3= i.getExtras().getInt("images", R.id.iv_flag);
Bitmap mImage1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
// /////////////////////////////INSTRUCT//////////////////
textmain.setText(hospitalpress);
textmain2.setText(hospitalpress2);
image.setImageResource(hodddddspitalpress3);
}
}
现在请告诉我我在第一个活动中写的内容以及我在第二个活动中写的内容,让imageview(在活动2中)显示(avtivity 1)列表视图中的图像
提示:listview中的图像来自mysql数据库,而不是可绘制的。
答案 0 :(得分:0)
如果你需要点击列表视图将数据从一个活动转移到另一个活动,那么请在下面提到(希望你可以自己做列表视图部分。希望你也创建了适配器类)
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(Service.this, SelectedService.class);
intent.putExtra("sp_name", m_ArrayList.get(arg2).sp_name);
intent.putExtra("image_url",
m_ArrayList.get(arg2).your_image);
startActivity(intent);
}
});