简体   繁体   English

在弹出的android中打开pdf

[英]open pdf in popup android

I am developing an Android app, where I need to open my pdf file in a popup window.我正在开发一个 Android 应用程序,我需要在弹出窗口中打开我的 pdf 文件。 My code is:我的代码是:

ImageView brobutton=(ImageView)layout.findViewById(R.id.imageView3);
brobutton.setOnClickListener(new OnClickListener() {
                                                   }
});

I already have developed an app to open pdf in emulator with this code:我已经开发了一个应用程序,可以使用以下代码在模拟器中打开 pdf:

final String googleDocsUrl = "http://docs.google.com/viewer?url=";
WebView mWebView=new WebView(SubProducts.this);                                         mWebView.getSettings().setJavaScriptEnabled(true);
WebSettings webSettings = mWebView.getSettings();
webSettings.setPluginState(PluginState.ON);
mWebView.setWebViewClient(new WebViewClient() {
    public boolean shouldOverrideUrlLoading(WebView view, String url){                                                          
        view.loadUrl(image_urlpdf);
        return false; // then it is not handled by default action
    }
});
mWebView.loadUrl((googleDocsUrl + image_urlpdf));

under the onclick of button I need to open my pdf.Any one suggest me with good idea.在 onclick 按钮下,我需要打开我的 pdf.Any 建议我有好主意。 Thanks in advance.提前致谢。

You need to modify your app to open PDF.您需要修改您的应用程序才能打开 PDF。 Either pass some flag using intents to alert that your app need to open popup for showing PDF.要么使用意图传递一些标志来提醒您的应用程序需要打开弹出窗口以显示 PDF。

Check this thread for how to show activity as dialog Android Activity as a dialog检查此线程以了解如何将活动显示为对话框Android 活动作为对话框

You could load your PDF file in the custom dialog.您可以在自定义对话框中加载您的 PDF 文件。 Tutorial for creating the custom dialog - http://www.mkyong.com/android/android-custom-dialog-example/创建自定义对话框的教程 - http://www.mkyong.com/android/android-custom-dialog-example/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM