Java 如何使用Jsoup将文本从html获取到TextView,而不使用按钮?
所以我写了这篇文章,但安卓工作室说“课堂新闻从未被使用”,我做错了什么Java 如何使用Jsoup将文本从html获取到TextView,而不使用按钮?,java,android,jsoup,Java,Android,Jsoup,所以我写了这篇文章,但安卓工作室说“课堂新闻从未被使用”,我做错了什么 public class news extends AsyncTask<Void,Void,Void> { String words; @Override protected Void doInBackground(Void... params) { try{ Document doc = Jsoup.connect("myurl").get();
public class news extends AsyncTask<Void,Void,Void> {
String words;
@Override
protected Void doInBackground(Void... params) {
try{
Document doc = Jsoup.connect("myurl").get();
Elements ele = doc.select("div#home-right");
words = ele.text();
}catch(Exception e){e.printStackTrace();}
return null;
}
TextView.setText(words);
}
公共类新闻任务{
字符串;
@凌驾
受保护的Void doInBackground(Void…参数){
试一试{
Document doc=Jsoup.connect(“myurl”).get();
元素ele=doc.select(“div#home right”);
words=ele.text();
}catch(异常e){e.printStackTrace();}
返回null;
}
TextView.setText(单词);
}
你必须给你的“新闻”课打电话。
所以在onCreate方法的活动中调用newnews(this.execute();
记住用大写字母上课。你必须给你的“新闻”课打电话。
所以在onCreate方法的活动中调用newnews(this.execute();
记住用大写字母上课。在活动课上,输入以下代码:
news n = new news();
n.execute();
在活动类中,输入以下代码:
news n = new news();
n.execute();
非常感谢。谢谢你。解决了的