gpt4 book ai didi

android - 使用 Jsoup 在 TextView 中显示单元格表格数据

转载 作者:行者123 更新时间:2023-11-28 03:15:21 25 4
gpt4 key购买 nike

我想在 TextView 中显示滑雪胜地过去 24 小时的雪景。我使用了 CSS 路径并尝试了其他方法,但没有任何反应 TextView 不显示任何内容。

网页:http://www.arizonasnowbowl.com/resort/snow_report.php

CSS 路径:#container > div.right > table.interior > tbody > tr:nth-child(2) > td.infoalt

private class Description extends AsyncTask<Void, Void, Void> {

String desc;

@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(Snowreport.this);
mProgressDialog.setTitle("Snow Report");
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}

@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
Document document = Jsoup.connect(url).get();
Elements elms = document.select("td.infoalt");
for(Element e:elms)
if(e.className().trim().equals("infoalt"))
//^^^<--trim is required as,
// their can be leading and trailing space
{

TextView txtdesc = (TextView) findViewById(R.id.snowp24);
txtdesc.setText((CharSequence) e);


}



mProgressDialog.dismiss();

} catch (IOException e1) {
e1.printStackTrace();
}

return null;
}

最佳答案

代码:

Element div = doc.getElementById("contentinterior");
Elements tables = div.getElementsByTag("table");
Element table = tables.get(1);

String mSnow = table.getElementsByTag("tr").get(1).getElementsByTag("td").get(1).text();

关于android - 使用 Jsoup 在 TextView 中显示单元格表格数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28390969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com