android - dynamically create button under dynamically created table -


i create table dynamically:

the header

void addheader() {         /** create tablerow dynamically **/         tr = new tablerow(this);         /** creating textview add row **/         label = new textview(this);         label.settext("inventarnummer");         label.setlayoutparams(new layoutparams(layoutparams.wrap_content,                 layoutparams.wrap_content));         label.setpadding(5, 5, 5, 5);         linearlayout ll = new linearlayout(this);         linearlayout.layoutparams params = new linearlayout.layoutparams(                 layoutparams.fill_parent, layoutparams.wrap_content);         params.setmargins(5, 5, 5, 5);         // ll.setpadding(10, 5, 5, 5);         ll.addview(label, params);         tr.addview((view) ll); // adding textview tablerow.          /** creating qty button **/         textview place = new textview(this);         place.settext("bezeichnung");         place.setlayoutparams(new layoutparams(layoutparams.wrap_content,                 layoutparams.wrap_content));         place.setpadding(5, 5, 5, 5);         // place.setbackgroundcolor(color.red);         ll = new linearlayout(this);         params = new linearlayout.layoutparams(layoutparams.fill_parent,                 layoutparams.wrap_content);         params.setmargins(0, 5, 5, 5);         // ll.setpadding(10, 5, 5, 5);         ll.addview(place, params);         tr.addview((view) ll); // adding textview tablerow.          /** creating qty button **/         textview place1 = new textview(this);         place1.settext("betriebszahl");         place1.setlayoutparams(new layoutparams(layoutparams.wrap_content,                 layoutparams.wrap_content));         place1.setpadding(5, 5, 5, 5);         // place.setbackgroundcolor(color.red);         ll = new linearlayout(this);         params = new linearlayout.layoutparams(layoutparams.fill_parent,                 layoutparams.wrap_content);         params.setmargins(0, 5, 5, 5);         // ll.setpadding(10, 5, 5, 5);         ll.addview(place1, params);         tr.addview((view) ll); // adding textview tablerow.          // add tablerow tablelayout         tl.addview(tr, new tablelayout.layoutparams(layoutparams.fill_parent,                 layoutparams.wrap_content));     } 

the button static under table, inside scrollview if table long, button outside visible area.

i need create button dynamically, below table (and inside table?)

i tried code below (and other codes):

void addfooder() {     /** create tablerow dynamically **/     tr = new tablerow(this);     /** creating textview add row **/     mybutton = new button(this);     mybutton.settext("send");     mybutton.setlayoutparams(new layoutparams(layoutparams.wrap_content,             layoutparams.wrap_content));      linearlayout ll3 = new linearlayout(this);     linearlayout.layoutparams params = new linearlayout.layoutparams(             layoutparams.fill_parent, layoutparams.wrap_content);     params.setmargins(5, 5, 5, 5);     // ll.setpadding(10, 5, 5, 5);     ll3.addview(label, params);     tr.addview((view) ll3); // adding textview tablerow.     // add tablerow tablelayout     tl.addview(tr, new tablelayout.layoutparams(layoutparams.fill_parent,             layoutparams.wrap_content));   } 

logcat:

java.lang.runtimeexception: unable start activity componentinfo{eu.straff/eu.straff.outacceptactivity}: java.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. 


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -