我开发了一个包含画布来绘制图像的活动,并且我有一个名为 calla 活动的菜单(此活动显示图片列表)。一旦我从列表中选择了一张图片,这张图片必须在画布上绘制。所以,我的问题是如何将这张图片从 Activity1 的 listView 发送到Activity2的画布。
这是我的代码:
活动1
case R.id.menu_prefs:
Intent i = new Intent(TpMainActivity.this, ListViewImagesActivity.class);
startActivity(i);
return true;
Acitvity2(列表查看图片)
public class ListViewImagesActivity extends Activity {
/** Called when the activity is first created. */
private PaintView paintView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<ItemDetails> image_details = GetSearchResults();
final ListView lv1 = (ListView) findViewById(R.id.listV_main);
lv1.setAdapter(new ItemListBaseAdapter(this, image_details));
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Thread thread = new Thread() {
// @Override
public void run() {
try {
InputStream bitmap=getAssets().open("a.gif");
Bitmap bit=BitmapFactory.decodeStream(bitmap);
paintView.setBitmap(bit);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
};
thread.start();
}
});
}