如何使用 Jsoup 从 html 获取文本到 TextView,没有按钮?
How to get text from html to TextView with Jsoup, no buttons?
所以我写了这个但是 Android Studio 说 "class news is never used" 我做错了什么?
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);
}
你必须打电话给你的 "news" class。
所以在activity的onCreate方法中调用new news(this).execute();
记得用大写字母制作class。
在您的 activity class 中,输入此代码:
news n = new news();
n.execute();
所以我写了这个但是 Android Studio 说 "class news is never used" 我做错了什么?
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);
}
你必须打电话给你的 "news" class。 所以在activity的onCreate方法中调用new news(this).execute(); 记得用大写字母制作class。
在您的 activity class 中,输入此代码:
news n = new news();
n.execute();