Intent intent = new Intent(context, MultiImageSelectorActivity.class);
// 是否显示拍摄图片,显示
intent.putExtra(MultiImageSelectorActivity.EXTRA_SHOW_CAMERA, true);
// 最大可选择图片数量 maxNum张
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_COUNT, maxNum);
// 选择模式,选取多张
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_MODE, MultiImageSelectorActivity.MODE_MULTI);
// 默认选择
if (mSelectPath != null && mSelectPath.size() > 0) {
// intent.putExtra(MultiImageSelectorActivity.EXTRA_DEFAULT_SELECTED_LIST, mSelectPath);
}
startActivityForResult(intent, REQUEST_IMAGE);
返回的
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE) {
if (resultCode == RESULT_OK) {
getPhotosPath(data);
}
}
}
//获取一堆图片路径s
public void getPhotosPath(Intent data) {
mSelectPath = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
for (String p : mSelectPath) {
//加入最后选择的集合
finalSelectPaths.add(p);
Log.e("路径", p);
// 发送图片
sendPhotoPath(p, "zhihui");//
//图片缩略图
Bitmap bitmap = Util.decodeSampledBitmapFromSd(p, 200, 200);
}
}
别完了加这个
compile project(':multi-image-selector')//图片选择器
还有这个
<!-- 图片选择器 -->
<activity
android:name="me.nereo.multi_image_selector.MultiImageSelectorActivity"
android:screenOrientation="portrait"
android:theme="@style/ColorTranslucentTheme" />
multi-image-selector 把这个文件夹 import进去