Tonight is gonna be a short post, it's just past midnight and I have to get up early tomorrow for work. I was planning to do some exercise tonight, but I got caught up writing code and watching a lifetime movie called "Pregnancy Project" or something like that, it turned out to be really quite good!
Anyway, I solved the widget problem, albeit in a method I'm not so proud of...
Here's the code I used to add rows to my widget layout, the row is defined in a file called "datarow.xml" :
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);
Note how I use this silly switch... I can't figure out how to iterate the stupid text views per row!! Anyway, it works more or less perfectly now and will update and give me my baseball scores in a nifty, but kinda large table... now I need to figure out how to resize it.
Here's a screenshot where I put a hanshin tiger bg to it:
Hard to read, on my phone I just have it with white text on a light-grey transparent bg.
see you space cowboys
1 comment:
Now I know this is not the mind of a mad man, or is it???Sounds foreign to me Keep up the good work. Donna P.
Post a Comment