Copy Code code as follows:
echo of a list of data
public void Shujulist () {
list<customer> customerlist = Dao.findall ();
Tablelayout tl = (tablelayout) Findviewbyid (r.id.tllayout);
LOG.I (">>>", String.valueof (Tl.getchildcount ()));
Int J = Tl.getchildcount ();
if (j>1) {
/*for (int i=0;i<j;i++) {
Tl.removeview (Tl.getchildat (j-i));//must subtract child elements from the back
}*/
for (int i=j;i>0;i--) {
Tl.removeview (Tl.getchildat (i));//must subtract child elements from the back
}
}
TableRow row = null;
for (Customer c:customerlist) {
row = new TableRow (this);
Id
TextView tvid = new TextView (this);
Tvid.settext (C.id + "");
Row.addview (Tvid);
Name
TextView tvname = new TextView (this);
Tvname.settext (C.name);
Row.addview (Tvname);
Age
TextView tvage = new TextView (this);
Tvage.settext (C.telenumber + "");
Row.addview (Tvage);
Tl.addview (row);
}
}