在我的代码中按下相机按钮后onActivityResult
调用(由于意图)。在这种方法中,我编写了将捕获的图像添加到listView
. 我想要的是,当我第二次捕获图像时,第一个图像listView
不应该消失。如果我已经拍摄了三次图像,那么应该有三个listview
项目。每次捕获图像时,我的代码仅显示一项。我已经尝试了很多,但无法弄清楚。谢谢。
ArrayList<HashMap<String, Object>> hashMapListForListView=new ArrayList<HashMap<String,Object>>();
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Activity.RESULT_OK )
{
if (requestCode == take_image) {
//get image
final Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
Viewimage.setImageBitmap(thumbnail);
Adapter=new SimpleAdapter(this,hashMapListForListView,R.layout.imageview2,new String[]{"image"}, new int[]{R.id.imageView2});
HashMap<String, Object>temp11=new HashMap<String, Object>();
//Drawable d = new BitmapDrawable(getResources(),thumbnail);
temp11.put("image",thumbnail);
hashMapListForListView.add(temp11);
listviewattachment.setAdapter(Adapter);
Adapter.setViewBinder(new MyViewBinder());
Adapter.notifyDataSetChanged();