我正在尝试使用 jsoup 从网站返回字符串并在 textview 中查看字符串,但出现此错误
类型获取器的方法 findViewById(int) 未定义
我的代码是:
public class Second extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_second, menu);
return true;
}
public void Iqama (View view) throws IOException
{
//Document doc = Jsoup.connect("http://google.com/").get();
new fetcher().execute();
}
}
类 fetcher 扩展 AsyncTask{ String myString = null;
@Override
protected Void doInBackground(Void... arg0) {
Document doc = null;
try {
doc = Jsoup.connect("http://www.ismmusalla.org/").get();
Elements divs = doc.select("div#title1");
for (Element div : divs) {
myString=myString+" " +div.text();
}
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String result)
{
TextView textview=(TextView)findViewById(R.id.textView1);
textview.setText(myString);
}
}
请你帮助我好吗 ????