Dynamically add ImageView to TableRow
<p>I have a TableLayout in my XML, and I'd like to dynamically add a TableRow with an ImageView to that TableLayout. What I have so far is this:</p>

<pre><code>TableRow tr = new TableRow(this);
ImageView imgView = new ImageView(this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                            LayoutParams.WRAP_CONTENT,
                            LayoutParams.WRAP_CONTENT);
imgView.setLayoutParams(lp);
imgView.setImageDrawable(getResources().getDrawable(R.drawable.icon_test));
tr.addView(imgView);
tlCollection.addView(tr);
</code></pre>

<p>What am I doing wrong? If I want to add a Textview to the same TableRow, it works, but adding an ImageView doesn't work.. </p>

<p>The code for adding a TextView:</p>

<pre><code>TextView myTextView = new TextView(this);

myTextView.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT,TableRow.LayoutParams.WRAP_CONTENT));
myTextView.setText("Test");
tr.addView(myTextView);
</code></pre>

<p>Any idea?</p>
