我正在为一个android应用程序提取一些html。我遇到的一个问题是下面代码中线程之后的代码没有被执行。我觉得我犯了一个业余错误,但我不明白它是什么。我知道数组列表正在被填充,从在 createTimetable() 方法中将它们的内容打印到 logcat 中。但是,之后的任何事情}).start();
都没有完成。有任何想法吗?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_online_timetable);
Intent intent = getIntent();
value = intent.getStringExtra("url");
new Thread(new Runnable() {
public void run() {
try {
Log.d("url",value);
doc = Jsoup.connect(value).get();
Element monday = doc.select("p ~ table").first();
Element tuesday = doc.select("p ~ table").get(1);
Element wednesday = doc.select("p ~ table").get(2);
Element thursday = doc.select("p ~ table").get(3);
Element friday = doc.select("p ~ table").get(4);
monday.select("tr:eq(0)").remove();
tuesday.select("tr:eq(0)").remove();
wednesday.select("tr:eq(0)").remove();
thursday.select("tr:eq(0)").remove();
friday.select("tr:eq(0)").remove();
final Elements mon = monday.select("td");
final Elements tues = tuesday.select("td");
final Elements wed = wednesday.select("td");
final Elements thurs = thursday.select("td");
final Elements fri = friday.select("td");
Log.d("thread","sdsddssd");
createTimetable(monClasses, mon, day1);
createTimetable(tuesClasses, tues, day2);
createTimetable(wedClasses, wed, day3);
createTimetable(thurClasses, thurs, day4);
createTimetable(friClasses, fri, day5);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
Log.d("sdfsdfsdf", "HELLO");
for(int i = 0; i<monClasses.size();i++)
{
Log.d("monday", monClasses.get(i).toString());
}
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
}