Android webview.loadData() 不显示制表符

Android webview.loadData() does not display tabs

我是 css 和 android 的新手。我正在尝试在 webview 中加载要点,但是当我使用 webview.loadData(content, "text/html", "utf-8"); 时代码的缩进没有出现 当我使用 webview.loadUrl(url); 时它运行良好但我想要以前的。我在这里错过了什么大事吗?哦,缩进是 css 属性 white-space: pre; 的要点。这是我的代码:

final WebView webview = (WebView)getActivity().findViewById(R.id.algoView);
webview.getSettings().setJavaScriptEnabled(true);
//webview.loadUrl("https://gist.github.com/tanaykumarbera/c9f7f3e7490a1c002649/" ); // works perfectly

AsyncHttpClient client = new AsyncHttpClient();
client.get("https://gist.github.com/tanaykumarbera/c9f7f3e7490a1c002649", new AsyncHttpResponseHandler() { 

        @Override
        public void onStart() {
        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] res) {
            String data="";
                ByteArrayInputStream b = new ByteArrayInputStream(res);
                String response = "";int c;
                while( (c = b.read()) != -1) {
                    response += Character.toString((char) c);
                }
                webview.loadData(response, "text/html", "utf-8"); // Not Working!!
        }

        @Override
        public void onFailure(int statusCode, Header[] headers,  byte[] errorResponse, Throwable e) {
        }

        @Override
        public void onRetry(int retryNo) {
        }
    });
}

截图:

http://postimg.org/image/rjz6e18fv/

http://postimg.org/image/u2kvepu63/

任何关于如何在本地加载它或者我应该阅读原始降价的想法将不胜感激,谢谢!

摆弄了一段时间后,我发现

 webview.loadData(response, "text/html", "utf-8");

使用

webview.loadDataWithBaseURL("", response, "text/html", "utf-8", null);

解决了这个问题,虽然我不知道为什么 css 选项卡不能使用以前的代码。