2017-04-18 7 views
-3

以下のコードはデバイスからの画像です。どのようにpdfをdevice.andから選択し、pdfをImageビューに表示するのですか?イメージビューで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(); 
       } 
      }); 
+0

'ImageView'は印刷用PDFをサポートしていません – snachmsm

+0

' pdf'ファイルは**画像ではありません**。例で –

答えて

0

、あなたはサムネイルがこれを確認してください作成するPDF

のサムネイルを作成する必要が画像として

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

をPDFファイルを設定するには、この

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

をお試しくださいPDFファイルを選択するにはこれがあなたを助けることを願っています。

+0

、私はボタンを押したときに私は両方の画像ファイルまたはpdf file.whatコードを選択したいですか? – spodee

+0

@spodeeはマルチプルMIMEタイプを渡します - これを確認してくださいhttp://stackoverflow.com/a/33117677/3416642 – Sach

+0

私はこのコードをしようとすると[Intent intent = new Intent(); intent.setType( "image/* | application/pdf"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent、 "Select Document")、1);]画像のみが選択されました。 – spodee

関連する問題