android - How can I add separating lines between my TableRows that are created programmatically? -


i have tablelayout created programmatically in android project. keep adding tablerows long there more rows fetched database. want add separating lines, border, between tablerows.

in other tablelayout created statically xml used view separator, style style.xml.

i tried adding view tablelayout so:

view v=new view(this);          v.setlayoutparams(new layoutparams(                  layoutparams.fill_parent,                  layoutparams.wrap_content));          v.setbackgroundresource(r.drawable.rowseparator_shape);              tr.addview(mtvdate);              tr.addview(mtvresult);               tl.addview(tr);               tl.addview(v); 

but gets added once after collected tablerows. smart way of adding 1 view each tr added? or should use else alltogether?

view v = new view(this); v.setlayoutparams(new tablerow.layoutparams(tablerow.layoutparams.fill_parent, 1)); v.setbackgroundcolor(color.rgb(51, 51, 51)); tr.addview(mtvdate); tr.addview(mtvresult);  tl.addview(tr);  tl.addview(v); 

here i'm creating view 1 pixel high specific background color. works me.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -