Is there a way that I can set the span of a textview object in the java code, instead of having to do it in xml? I tried someone else's solution of using LayoutParams. I don't know if i didn't implement it correctly or if its just the wrong solution or maybe im just not realizing what my mistake in the code is, but it's causing the application to crash. Any help would be appreciated, im posting my 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> a : 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()
{
}
}