我可以使用 xml 解析将选定的列表视图文本发送到另一个活动,但无法将选定的图像提取到下一个活动,我在这里放置我的代码,请找出我没有将图像发送到另一个活动的原因:-
主要活动代码:-
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HashMap<String, String> map = pizzaList.get(position);
Intent in = new Intent(MainActivity.this, SecondActivity.class);
in.putExtra(KEY_TITLE, map.get(KEY_TITLE));
in.putExtra(KEY_DESCRIPTION, map.get(KEY_DESCRIPTION));
in.putExtra(KEY_THUMB_URL, map.get(KEY_THUMB_URL));
in.putExtra(KEY_COST, map.get(KEY_COST));
startActivity(in);
}
});
第二活动代码:-
Intent in = getIntent();
final String title = in.getStringExtra(KEY_TITLE);
final String description = in.getStringExtra(KEY_DESCRIPTION);
final String thumb_url = in.getStringExtra(KEY_THUMBURL);
final String cost = in.getStringExtra(KEY_COST);
TextView title = (TextView) findViewById(R.id.single_title);
TextView description = (TextView) findViewById(R.id.single_description);
TextView cost = (TextView) findViewById(R.id.single_cost);
ImageLoader imageLoader = new ImageLoader(getApplicationContext());
ImageView thumb = (ImageView) findViewById(R.id.single_image);
title.setText(title);
description.setText(description);
cost.setText(cost);
imageLoader.DisplayImage(thumb_url, thumb);