如何选择在android中同时添加多个图像?

时间:2016-03-14 06:58:40

标签: android gridview filechooser

我正在设计发布一些图片。我有以下设计。帮助我如何在gridview item.demo图像中添加按钮

enter image description here

这是我正在尝试的代码。

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == RESULT_OK && null != data)
{
Uri selected_image = data.getData();
String[] filepath = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selected_image, filepath, null, null, null);
cursor.moveToFirst();
column_index = cursor.getColumnIndexOrThrow(filepath[0]);
String picture_path = cursor.getString(column_index);
cursor.close();
Log.d(TAG, "Sended image path " + picture_path);
imagepath = picture_path;
// ImageView imageView = (ImageView) findViewById(R.id.imageView2);
// imageView.setImageBitmap(BitmapFactory.decodeFile(imagepath));
gridAdapter = new GridViewAdapter(this, R.layout.imageview, getData());
gridview.setAdapter(gridAdapter);
// boolean galleryimagestatus = true;
// photoSorter.addImages(MainActivity.this, R.drawable.ic_launcher);
}
}
private ArrayList<ImageItem> getData() {
final ArrayList<ImageItem> imageItems = new ArrayList<>();
// TypedArray imgs = getResources().obtainTypedArray(column_index);
// for (int i = 0; i < imgs.length(); i++) {
Bitmap bitmap = BitmapFactory.decodeFile(imagepath);
Log.d(TAG,"bitmap "+bitmap);
imageItems.add(new ImageItem(bitmap, "Image#"));
// }
return imageItems;
}
}

0 个答案:

没有答案