create EditText view row in Android -


i've managed add edittext(s) dynamically , retrieve values in android, , got program code here (sample below)

public class sample extends activity {     private list<edittext> edittextlist = new arraylist<edittext>();      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          linearlayout linearlayout = new linearlayout(this);         viewgroup.layoutparams params = new viewgroup.layoutparams(fill_parent, wrap_content);         linearlayout.setlayoutparams(params);         linearlayout.setorientation(vertical);          int count = 10;         linearlayout.addview(tablelayout(count));         linearlayout.addview(submitbutton());         setcontentview(linearlayout);     }      private button submitbutton() {         button button = new button(this);         button.setheight(wrap_content);         button.settext("submit");         button.setonclicklistener(submitlistener);         return button;     }      // access value of edittext      private view.onclicklistener submitlistener = new view.onclicklistener() {         public void onclick(view view) {             stringbuilder stringbuilder = new stringbuilder();             (edittext edittext : edittextlist) {                 stringbuilder.append(edittext.gettext().tostring());             }         }     };      // using tablelayout provides neat ordering structure      private tablelayout tablelayout(int count) {         tablelayout tablelayout = new tablelayout(this);         tablelayout.setstretchallcolumns(true);         int noofrows = count / 5;         (int = 0; < noofrows; i++) {             int rowid = 5 * i;             tablelayout.addview(createonefullrow(rowid));         }         int individualcells = count % 5;         tablelayout.addview(createleftovercells(individualcells, count));         return tablelayout;     }      private tablerow createleftovercells(int individualcells, int count) {         tablerow tablerow = new tablerow(this);         tablerow.setpadding(0, 10, 0, 0);         int rowid = count - individualcells;         (int = 1; <= individualcells; i++) {             tablerow.addview(edittext(string.valueof(rowid + i)));         }         return tablerow;     }      private tablerow createonefullrow(int rowid) {         tablerow tablerow = new tablerow(this);         tablerow.setpadding(0, 10, 0, 0);         (int = 1; <= 5; i++) {             tablerow.addview(edittext(string.valueof(rowid + i)));         }         return tablerow;     }       } 

this output printscreen http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash3/582244_3038340529251_1585166028_31994124_463408868_n.jpg

how can make edittext view shown picture below? http://a6.sphotos.ak.fbcdn.net/hphotos-ak-ash4/s720x720/401912_3038335049114_780299491_n.jpg

linearlayout main,clild; main = new linearlayout(....); // vertical orientation main.setorientation(linearlayout.vertical);   for(int i=0;i<5;i++) {     child = new linearlayout(...); // horizontal orientation     child.setorientation(linearlayout.horizontal);     for(int j=0;j<i;j++)     {        edittext ed = new edittext(...);        child.addview(ed);     }     main.addview(child); } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -