所以我写了这个,但是Android Studio说“从来没有使用过类新闻”我在做什么错?
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);
}
答案 0 :(得分:1)
您必须调用“新闻”类。 因此,在活动中的onCreate方法中调用new news(this).execute();。 记住使用大写字母上课。
答案 1 :(得分:1)
在您的活动班级中,输入以下代码:
news n = new news();
n.execute();