I try to open .pdf file's in webview. I wrote code which can show pdf in webview.
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.
My webview looks like this:
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;
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.