如何在选择器Intent中添加删除按钮

时间:2015-12-29 10:31:22

标签: java android android-intent

我有一个包含Imageview的活动,当点击此图像视图时,此选择器开始在图像视图中设置图像。它运作良好,但我想在此选择器意图中添加删除按钮 例如,如果活动中的Imageview有图像,我想通过删除按钮

从该选择器中删除该图像 enter image description here

这也是我对此选择器的代码(此代码是我活动的一部分):

 final List<Intent> cameraIntents = new ArrayList<Intent>();
    final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    final PackageManager packageManager = getPackageManager();
    final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
    for (ResolveInfo res : listCam) {
        final String packageName = res.activityInfo.packageName;
        final Intent intent = new Intent(captureIntent);
        intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        intent.setPackage(packageName);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        cameraIntents.add(intent);
    }

    // Filesystem.
    final Intent galleryIntent = new Intent();
    galleryIntent.setType("image/*");
    galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

    // Chooser of filesystem options.
    final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.select_source));

    // Add the camera options.
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
    chooserIntent.putExtra(Intent.EXTRA_DATA_REMOVED,del);
    startActivityForResult(chooserIntent, 12312);

请您帮我添加删除按钮,以便在此选择器中从imageview中删除图像?

0 个答案:

没有答案