java - Dynamic Span Adjustment for TextView In TableLayout -
is there way can set span of textview object in java code, instead of having in xml? tried else's solution of using layoutparams. don't know if didn't implement correctly or if wrong solution or maybe im not realizing mistake in code is, it's causing application crash. appreciated, im posting code below.
package com.szymon.atrium; import java.util.arraylist; import java.util.gregoriancalendar; import android.app.activity; import android.os.bundle; import android.widget.tablelayout; import android.widget.tablerow; import android.widget.tablerow.layoutparams; public class tapechart extends activity { private arraylist<room> rooms; private arraylist<arrival> arrivals; private gregoriancalendar startdate = new gregoriancalendar(2011,1,1); private gregoriancalendar enddate = new gregoriancalendar(2011,1,10); private arrivalgrid grid = new arrivalgrid(arrivals, rooms, startdate.gettime(), enddate.gettime()); private arraylist<arraylist<cell>> displayarrival = grid.displayarrivalgrid(); private arraylist<arraylist<cell>> displayrooms = grid.displayroomgrid(); @override public void oncreate(bundle bundle) { super.oncreate(bundle); setcontentview(r.layout.tape); tablelayout tbl = (tablelayout)findviewbyid(r.id.tapechart); for(arraylist<cell> : displayrooms) { tablerow newrow = new tablerow(this); for(cell c : a) { layoutparams param = new layoutparams(); param.span=c.getcolspan(); mytextview cell = new mytextview(this); cell.settext(c.getcontent()); cell.setlayoutparams(param); newrow.addview(cell); } tbl.addview(newrow); } } public tablelayout getarrivalstablelayout() { return null; } public void getroomtablelayout() { } }
with aid of code @ link, have accomplish issue
`tablerow.layoutparams rowspanlayout = new tablerow.layoutparams(tablerow.layoutparams.fill_parent, tablerow.layoutparams.wrap_content); rowspanlayout.span = 3; textview textview = new textview(this); textview.settext("text title"); tablerow.addview(textview, rowspanlayout);` while creating rows dynamically @ java code side.
Comments
Post a Comment