How to set a view layout column in code (view is inside tablerow)?

I have a tablelayout in xml. I also add a few lines in the code to it. How can I set some kind of column_layout in code?

In xml, I have:

android:layout_column="3"

How to achieve the same code (for example, for TextView)?

+3
source share
2 answers
        TextView tv = new TextView(this); 
        tv.setLayoutParams(new TableRow.LayoutParams(3));
+7
source

I'm not quite sure I understand the questions, however MyTracks for Android provides a good example code using a table layout. Here can be found here .

Thanks for the comment. I think this is what you are looking for: <TableLayout xmlns: android = "http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="3">

<TableRow>
    <TextView
        android:layout_column="1"
        android:text="Open..."
        android:padding="3dip" />
    <TextView
        android:text="Ctrl-O"
        android:gravity="right"
        android:padding="3dip" />
    <TextView
        android:text="String"
        android:gravity="right"
        android:padding="3dip" />
</TableRow> ...`
0
source

All Articles