这是我让它工作的一种方法:
rv2 = new RemoteViews(this.getApplicationContext()
.getPackageName(), R.layout.datarow);
if(tr.hasClass("title"))
i = 1;
else
i = 0;
for (Element td : tds) {
if (td.getElementsByTag("a").size() > 0) {
Elements anchors = td.getElementsByTag("a");
td.text(anchors.get(0).text());
rv2.setTextViewText(R.id.textView2,
td.text());
} else {
switch (i) {
case 0:
rv2.setTextViewText(R.id.textView1,
td.text());
i++;
break;
case 1:
rv2.setTextViewText(R.id.textView3,
td.text());
i++;
break;
case 2:
rv2.setTextViewText(R.id.textView4,
td.text());
i++;
break;
case 3:
rv2.setTextViewText(R.id.textView5,
td.text());
i++;
break;
case 4:
rv2.setTextViewText(R.id.textView6,
td.text());
i++;
break;
default:
break;
}
}
}
remoteViews.addView(R.id.layout, rv2);
它不漂亮,我不喜欢使用开关,但我不知道如何遍历文本视图。如果有人能给我一个更好的答案,我会再开一段时间。