I have the next layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/foto"
android:scaleType="fitCenter"
android:layout_width="70dp"
android:layout_height="70dp"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:paddingLeft="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:id="@+id/nombre"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#ffffff"
android:textSize="16sp" />
<TextView
android:layout_width="fill_parent"
android:id="@+id/posicion"
android:textColor="#ffffff"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
And I would like to set this layout to a TableRow programmatically.
Any idea?
Thanks.
As Cristian suggested, using LayoutInflater solved my problem.
This is the code for my activity:
I “inflate” one View with the layout which I would like to insert into each row, and I take the components inside the Layout, manipulate them, and then insert the View into the row.
Finally, just I have to insert the row into the Table and That’s it!.
Thanks a lot.