有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在安卓的图像视图中显示pdf?

下面的代码是从设备中拾取图像。如何从设备中选择pdf。以及如何在图像视图中显示pdf

  bt_gall .setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent();
                    // Show only images, no videos or anything else
                    intent.setType("image/*");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    // Always show the chooser (if there are multiple options available)
                    startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
                    alertDialog.dismiss();
                }
            });

共 (1) 个答案

  1. # 1 楼答案

    要选择pdf,请尝试以下操作

    Intent intent = new Intent();
            intent.setType("application/pdf");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "Select PDF"), 1);
    

    要将Pdf设置为图像,您需要创建Pdf的缩略图

    要创建缩略图,请选中此复选框

    https://stackoverflow.com/a/38829523/3416642

    希望这对你有帮助