jsoup不支持另一个languge? [英] jsoup not support another languge?

查看:161
本文介绍了jsoup不支持另一个languge?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望显示特定的网络div。我的代码正确和工作英语坐,但例如不工作与阿拉伯语,甚至不固定在标准位置虽然那坐的响应编码。

want show specific div of web . my code correct and work for English sit but for example not work with Arabic Language even not fixed in standard position Although that sit have responsive coding.

这是我的代码:

public class card_activity extends AppCompatActivity {

public WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.card_activity);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        Bundle b = getIntent().getExtras();
        final String receivingdata = b.getString("Key");


        webView=(WebView)findViewById(R.id.web);
        webView.getSettings().setJavaScriptEnabled(true);


        new AsyncTask<Void, Void, String>() {
            @Override
            protected String doInBackground(Void... voids) {
                String html = "";
                try {
                    Document document = Jsoup.connect(receivingdata).timeout(20000).get();
                    Element elements=document.select("div.base-box:nth-child(2)").first();
                    html = elements.toString();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return html;
            }
            @Override
            protected void onPostExecute(String html) {

                String mime = "text/html";
                String encoding = "utf-8";
                webView.loadData(html, mime, encoding);

            }
        }.execute();
}
}

这是另一种语言的结果:

and this my result for another language :

如何显示那部分坐在固定位置和正确的语言?

how can show that part of sit in fix position and correct language ?

推荐答案

经过这么多的尝试,我认识不能这样做与jsoup设置。只需使用 webView.loadDataWithBaseURL(null,html,mime,encoding,null); ,而不是 webView.loadData(html,mime,encoding) code>并显示任何语言轻松!

after so many try i recognize cant do that with jsoup setting . just use webView.loadDataWithBaseURL(null,html, mime, encoding,null);instead webView.loadData(html, mime, encoding); and show any language easy!

这篇关于jsoup不支持另一个languge?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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