0
IM尝试将网站的动态某些内容加载到web视图,但我不能 我使用此代码`公共类MainActivity延伸活动{显示一个网站的某些内容到网页视图
// blog url
static final String BLOG_URL = "http://www.internationalnewscenter.com/";
@Override
public void onCreate(Bundle savedInstanceState) {
// set layout view
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// process
try {
((TextView)findViewById(R.id.textView1)).setText(getBlogStats());
} catch (Exception ex) {
((TextView)findViewById(R.id.textView1)).setText("Error");
}
}
protected String getBlogStats() throws Exception {
String result = "";
// get html document structure
Document document = Jsoup.connect(BLOG_URL).get();
// selector query
Elements nodeBlogStats = document.select("div#lofslidecontent45");
// check results
if(nodeBlogStats.size() > 0) {
// get value
result = nodeBlogStats.get(0).text();
}
// return
return result;
}
} 但它显示我的一个“错误”` 是任何一个能帮助我或者给我一个链接,完整的例子做
add ex.printstacktrace();并告诉我什么显示了控制台 – Xenione
在哪里我应该加上 – DoctorDoom
} catch(Exception ex){ex.printstacktrace(); ((TextView)findViewById(R.id.textView1))。setText(“Error”); } – Xenione