嘿,我试图采取一个网站的特定部分,然后显示在我的网络视图,但问题是,当我这样做,在较小的屏幕上的字母得到所有窃听的口音和东西,有没有任何方法,我可以转移只是一个特定的div的网站到我的网络视图,而不是这个窃听之一?
我在这个网站上需要的部分叫做:“inside2”
这是网站:http://www.dges.gov.pt/guias/detcursopi.asp?codc=8184&code=0400
我加载信息的代码:
private class MyTask extends AsyncTask<String, Integer, String> {
// Runs in UI before background thread is called
@Override
protected void onPreExecute() {
super.onPreExecute();
}
// This is run in a background thread
@Override
protected String doInBackground(String... params) {
// get the string from params, which is an array
Bundle CursoInfoData = getIntent().getExtras();
site = CursoInfoData.getString("site");
Document doc = null;
try {
doc = Jsoup.connect(site).get();
} catch (IOException e) {
e.printStackTrace();
}
ele = doc.select(".inside2");
return "start";
}
// This is called from background thread but runs in UI
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
// Do things like update the progress bar
}
// This runs in UI when background thread finishes
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
String text = "<html><head>"
+ "<style type=\"text/css\">body{color: #01A9DB; background-color: #FFFFFF;}"
+ "</style></head>"
+ "<body>"
+ ele.toString()
+ "</body></html>";
cursoInfoWeb.loadData(text, "text/html", "utf-8");
}
bugged form that I told you
最佳答案
我想你有utf-8的问题。使用这个:
cursoInfoWeb.loadDataWithBaseURL(null, text, "text/html", "UTF-8", null);
参考:SO answer
关于java - 将网站的<div>解析为webview,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46008246/