android - Can't display dynamically made grid layout -
here code create dynamic text views , create grid layout. grid layout not showing
tablerow[] tr = new tablerow[arry1.length]; final textview[] tx = new textview[arry1.length]; gridlayout tl = (gridlayout) findviewbyid(r.id.tablelayout1); tl.setrowcount(arry1.length*2); tl.setcolumncount(1); final button = new button(s1.this); b.settext("hi"); gridlayout[] gl = new gridlayout[arry1.length]; (i = 0; < arry1.length; i++) { final string cat = arry1[i].tostring(); tx[i] = new textview(s1.this); tx[i].setlayoutparams(new tablerow.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content)); tx[i].setallcaps(true); tx[i].settextsize(15); tx[i].settext(cat); gl[i] = new gridlayout(s1.this); gl[i].setlayoutparams(new layoutparams(layoutparams.wrap_content,layoutparams.wrap_content)); gl[i].setvisibility(view.visible); tr[i] = new tablerow(s1.this); tr[i].setlayoutparams(new layoutparams(layoutparams.wrap_content,layoutparams.wrap_content)); tr[i].addview(tx[i],new tablerow.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content)); tl.addview(tr[i],new gridlayout.layoutparams()); tl.addview(gl[i], new gridlayout.layoutparams()); tx[i].setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { category_main = cat; gl[i].addview(but); // exception } }); }
when run above code shows me text views doesn't shows me grid layout , button.
even if don't add button in grid layout grid layout not shown.
exception thrown when add button dynamically made grid layout
please me.
Comments
Post a Comment