文件显示,从谷歌文档中的WebView [英] Showing document from Google Docs in a WebView

查看:136
本文介绍了文件显示,从谷歌文档中的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题与显示的WebView(Android版)谷歌文档

Problem with showing google docs in WebView (Android)

这是我的code

mWebView=(WebView)findViewById(R.id.web);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("https://docs.google.com/viewer?url="+ "https://docs.google.com/file/d/0B7pKTkDz8c3gWGNRTWJidTBTVmc/edit?usp=sharing");

当我点击的这里的我的Andr​​oid显示选项中打开链接(如浏览器,浏览器,驱动器,互联网)并打开链接,以及在弹出的浏览器!

when i click here my android shows options to open the link (like Browser, Chrome, Drive, Internet) and opens the link well in popup Browser!

推荐答案

谷歌是你重定向到另一个网址,而的WebView 是让操作系统来处理重定向。

How To Force Android WebView to Process Redirects

Google is redirecting you to another URL, and the WebView is allowing the OS to process the redirect.

使用此code为的WebView 来内部处理重定向:

Use this code for the WebView to internally process redirects:

    // By default, redirects cause jump from WebView to default
    // system browser. Overriding url loading allows the WebView  
    // to load the redirect into this screen.
    mWebView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }
    });

顺便说一句,你可以做很多其他很酷的东西在这个函数中,如各种URL的自定义操作。

Incidentally, you can do lots of other cool stuff in this function, such as custom handling of various URLs.

这篇关于文件显示,从谷歌文档中的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆