Java 如何在android图像视图中显示pdf?
下面的代码是从设备中拾取图像。如何从设备中选择pdf以及如何在图像视图中显示pdfJava 如何在android图像视图中显示pdf?,java,android,pdf,Java,Android,Pdf,下面的代码是从设备中拾取图像。如何从设备中选择pdf以及如何在图像视图中显示pdf bt_gall .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(); // S
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();
}
});
要选择pdf,请尝试以下操作
Intent intent = new Intent();
intent.setType("application/pdf");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), 1);
要将Pdf设置为图像,您需要创建Pdf的缩略图
要创建缩略图,请选中此复选框
希望这能对您有所帮助。
ImageView
不支持打印pdfpdf
文件不是图像。例如,当我按下按钮时,我想同时选择图像文件或pdf文件。代码是什么?@spodee pass multple MIME type-尝试此代码时检查此代码[Intent Intent=new Intent();intent.setType(“image/*| application/pdf”);intent.setAction(intent.ACTION_GET_CONTENT);intent.addCategory(intent.CATEGORY_OPENABLE);startActivityForResult(intent.createChooser(intent,“选择文档”),1);]只选择了图像。