title: creating dynamic table in android
body: <p>I am trying to create a table from a 2-D array of strings. However, I suck in creating views in code, so for some reason my image is never visible and my textviews won't break into multilines, instead they chop of the text.</p>
  
  <p>Also, I put id on every textview in my code, when someone click the textview, I was hoping I could use that ID to identify whick row was clicked. Unfortunately that wasn't the case.</p>
  
  <p>Are there any good ways to identify correct row?</p>
  
  <p>Regards</p>
  
  <pre><code>      for (int current=0; current&lt;cityArr.length; current++) {
  
        TableRow tr = new TableRow(this);
        tr.setId(100+current);
        tr.setLayoutParams(new LayoutParams(
                LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT));   
  
        TextView labelTV = new TextView(this);
        labelTV.setId(current);
        labelTV.setText(cityArr[current][0]);
        labelTV.setTextColor(Color.BLACK);
        labelTV.setLayoutParams(new LayoutParams(
                LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT));
        tr.addView(labelTV);
  
        ImageView mapView = new ImageView(this);
        mapView.setImageResource(R.drawable.list_icon_map);
        mapView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT, 5));
        tr.addView(mapView);
  
        tlcity.addView(tr, new TableLayout.LayoutParams(
                LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT));
    }
  </code></pre>