[英]Android open pdf in webview
I try to open .pdf file's in webview.我尝试在 webview 中打开 .pdf 文件。 I wrote code which can show pdf in webview.我编写了可以在 webview 中显示 pdf 的代码。
I am using " http://docs.google.com/gview?embedded=true&url= " google drive to open pdf files on docs.google but i want to change the webview design for example I want to change the title, color etc. of my webview.我正在使用“ http://docs.google.com/gview?embedded=true&url= ”谷歌驱动器在 docs.google 上打开 pdf 文件,但我想更改 webview 设计,例如我想更改标题、颜色等. 我的网络视图。
My webview looks like this:我的网络视图如下所示:
http://postimg.org/image/cpb46c80x/ http://postimg.org/image/cpb46c80x/
Code代码
public class MainActivity extends Activity
{
public WebView web;
... ...
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.webView1);
web.getSettings().setJavaScriptEnabled(true);
// web.getSettings().setPluginState(PluginState.ON);
web.setWebViewClient(new WebViewClient());
String pdfURL = "http://dl.dropboxusercontent.com/u/37098169/Course%20Brochures/AND101.pdf";
web.loadUrl("http://docs.google.com/gview?embedded=true&url="
+ pdfURL);
// setContentView(web);
}
}
Try this.尝试这个。
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.