0

assetAndroid では、フォルダー内にある PDF ファイルをビューに表示する必要があります。サンプルコードを手伝ってくれる人はいますか?

4

1 に答える 1

0

ビューに表示することはできないと思います。そのためには、 を作成してからIntent、外部プログラムを呼び出す必要があります。

File sd = new File("example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(sd));
intent.setDataAndType(Uri.fromFile(sd), "application/pdf");
try {
    getContext().startActivity(intent);
} catch(ActivityNotFoundException e){
    // Show a message that a PDF viewer is not installed
    Toast.makeText("No PDF reader available",Toast.LENGTH_LONG).show();
}
于 2012-01-03T23:05:24.733 に答える