【发布时间】:2014-01-22 14:09:57
【问题描述】:
我尝试在 webview 中打开 .pdf 文件。我编写了可以在 webview 中显示 pdf 的代码。
我正在使用“http://docs.google.com/gview?embedded=true&url=”谷歌驱动器在 docs.google 上打开 pdf 文件,但我想更改 webview 设计,例如我想更改 webview 的标题、颜色等。
我的网页视图如下所示:
http://postimg.org/image/cpb46c80x/
代码
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);
}
}
【问题讨论】: