Prerak Prerak - 18 days ago 9
Android Question

Table with dynamic number of columns in Android

I want to create a table with dynamic number of columns in android I know how to add rows dynamically using LayoutInflator but how to add columns dynamically?

Thank you for your time any help is highly appreciated.

Answer

you dont add columns - only rows and after that you can tell every view how many columns need to span

android:layout_span 

Defines how many columns this child should span. Must be >= 1. 

Must be an integer value, such as "100". 

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type. 

This corresponds to the global attribute resource symbol layout_span.

http://developer.android.com/reference/android/widget/TableRow.LayoutParams.html#attr_android:layout_span

one of the best Tuts: http://mobile.tutsplus.com/tutorials/android/android-sdk_table-layout/

Comments