Sunday, 1 September 2013

Clone Rows in in table layout

Clone Rows in in table layout

I have the following my_layout.xml layout
<TableLayout android:id="@+id/tlTable" android:layout_width="match_parent"
android:layout_height="wrap_content" android:stretchColumns="1,2"
android:layout_marginTop="20dp" >
<TableRow android:id="@+id/trRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/tv1" style="@style/showtext_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Row1"
android:layout_marginRight="5dp"/>
<ProgressBar android:id="@+id/p2"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/greenprogress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="0" />
</TableRow >
</TableLayout>
I want to dynamically create 10 rows where all of them are clones of the
first Row except that the text of the first textview of each row (namely
tv1) to be changed to have the Row number. So it will be Row1, Row2 ,
Row3.....Row10
How can I achieve that?

No comments:

Post a Comment