-1

I'm running this code and the emulator is posting a force quit. Does anyone know what could be wrong?

TableLayout tl = (TableLayout)findViewById(R.id.tableLayout1);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

ImageView IV = new ImageView(this);
IV.setBackgroundResource(R.drawable.celtics);
IV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
        tr.addView(IV);
        tl.addView(tr);
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
locoboy
  • 38,002
  • 70
  • 184
  • 260
  • 1
    Please provide the stack trace. Stack trace is the information about the exception thrown by your app. It helps to understand and solve the problem. – Mudassir Mar 03 '11 at 03:51
  • Where is this code being run? I had this issue when I put the findViewById() before I called the setContentView() – Spidy Mar 03 '11 at 03:53
  • It looks like you are adding the tablerow before adding the table layout. – Phobos Mar 03 '11 at 04:52

1 Answers1

-1

I actually found a way to get around this by doing this dynamically. I deleted the xml file and created the table in Java

locoboy
  • 38,002
  • 70
  • 184
  • 260