Monday, 15 August 2011

android - Why would my dynamically generated content not show up in tablelayout -



android - Why would my dynamically generated content not show up in tablelayout -

i trying load buttons table layout within fragment. why not show up. see changing background works (changed gray reddish in oncreateview(......)) when phone call loadallbuttons not show up.

public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { if(container == null) homecoming null; basedview = (tablelayout) inflater.inflate(r.layout.fragment_difficult_sound_syllable, container, false); currentsyllable = getarguments().getstring(staticvalues.difficult_sound_selector); basedview.setbackgroundcolor(color.red); homecoming basedview; }

below loadallbuttons, , before asks yes says loaded (e.g. buttons , rows added, checked via logcat after row.add() , basedview.add())

private void loadallbuttons() { databasehelper tmphelper = new databasehelper(getactivity().getapplicationcontext()); arraylist<buttoninfocontainer> tmparray = null; if(currentsyllable.contentequals(staticvalues.consonant)) { tmparray = tmphelper.returnallconsonants(); log.i(staticvalues.tag, "returned consonants"); } else { tmparray = tmphelper.returnallvowels(); log.i(staticvalues.tag, "returned vowels"); } if(tmparray != null) { tablerow row = null; infobutton tmpbutton = null; //layoutparams rowparams = new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content); //tablerow.layoutparams equalparams = new tablerow.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content, 0); linearlayout.layoutparams buttonlayout = new linearlayout.layoutparams(layoutparams.fill_parent, layoutparams.fill_parent); if(basedview != null) { for(int = 0; < tmparray.size(); i++) { //adds new row table if modulus 0 if(( % 2 ) == 0) { row = (tablerow) getlayoutinflater(getarguments()).inflate(r.layout.table_row, null); //row.setlayoutparams(rowparams); basedview.addview(row); } tmpbutton = (infobutton) getlayoutinflater(getarguments()).inflate(r.layout.info_button, null); tmpbutton.setbackgroundresource(r.drawable.button_bg); tmpbutton.setlayoutparams(buttonlayout); //set button text tmpbutton.settext(tmparray.get(i).buttontext); //obtain held info tmpbutton.setextrainfo(tmparray.get(i).infoheld); //tmpbutton.setwidth(buttonwidth); //tmpbutton.setheight(buttonheight); //tmpbutton.settextsize(typedvalue.complex_unit_dip, textsize); tmpbutton.settextcolor(getresources().getcolor(r.color.button_text_color)); tmpbutton.settypeface(typeface.default_bold); row.addview(tmpbutton); tmpbutton.setonclicklistener(listenerdynamicbutton); } } } }

for reason though logcat outputs show (buttons showing proper names right amount of buttons) table layout not populated.

figured out reply in regards own problem. after

tmpbutton = (infobutton) getlayoutinflter()...

to

row.addview(tmpbutton);

had deleted except

tmpbutton.settext();

and

tmpbutton.setextrainfo(..);

although not know why killed layout. if figures part out gladly take answer.

android dynamic android-tabhost fragment android-tablelayout

No comments:

Post a Comment