How to display array in table on Android -


i have class like

public class items {     public int icon;     public string label;     public string price;     public string offer;     public items(){         super();     }      public items(int icon, string label,string price,string offer) {         super();         this.icon = icon;         this.label = label;         this.price = price;         this.offer = offer;     } } 

and created objects class like

items items_data[] = new items[] { new items(r.drawable.ic_launcher, "samsung","400","hot item"), new items(r.drawable.ic_launcher, "samsung1","4001","hot item1"),  }; 

now need display above value in table row in first row have display first position , on.. please help.

you can try this:

items items_data[] = new items[] {     new items(r.drawable.ic_launcher, "samsung", "400", "hot item"),     new items(r.drawable.ic_launcher, "samsung1", "4001", "hot item1"), };  tablelayout tl = new tablelayout(this);  (items items : items_data) {     tablerow tr = new tablerow(this);      imageview iv = new imageview(this);     iv.setbackgroundresource(items.icon);     tr.addview(iv);      textview label = new textview(this);     label.settext(items.label);     tr.addview(label);      textview price = new textview(this);     price.settext(items.price);     tr.addview(price);      textview offer = new textview(this);     offer.settext(items.offer);     tr.addview(offer);      tl.addview(tr); }  your_layout.add(tl); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -