问题
I am developing an Android app, where I need to open my pdf file in a popup window. 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:
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. Thanks in advance.
回答1:
You need to modify your app to open PDF. Either pass some flag using intents to alert that your app need to open popup for showing PDF.
Check this thread for how to show activity as dialog Android Activity as a dialog
回答2:
You could load your PDF file in the custom dialog. Tutorial for creating the custom dialog - http://www.mkyong.com/android/android-custom-dialog-example/
来源:https://stackoverflow.com/questions/15743179/open-pdf-in-popup-android