Hi,
I have the following problem spanning dynamically added
rows to a TableLayout inside a scroll view. The rows follow
this pattern:

Row 1: Cell spanned over the whole table
Row 2: Two cells
Row 3: Cell spanned over the whole table
...
Row N: Two cells

The problems is that the row with the one cell spanning
over the row actually does not span at all. It reaches at
some point in the middle of the screen and just wraps at
height.

Note that the samples below are oversimplified (but still
spanning does not work). They are ready to try - just create
the files. I debugged and it seems that the layout is
somehow disappearing along the way. Additionally, if the
TableLayout is hard-coded in the main.xml file, then there
are no problems. Unfortunately, I need to have views
dynamically generated.


 ----------------------------
TestProject.java
 ----------------------------
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class TestProject extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout table = new TableLayout(this);
ScrollView contentHolder = (ScrollView) find
contentHolder.addView(table, new TableLayout
TableLayout.LayoutParams.FILL_PARENT
TableRow row1 = (TableRow) View.inflate(this
TableRow.LayoutParams rowSpanLayout = new Ta
TableRow.LayoutParams.FILL_PARENT, T
rowSpanLayout.span = 2;
table.addView(row1, rowSpanLayout);
TableRow row2 = (TableRow) View.inflate(this
table.addView(row2);
}
}

----------------------------
main.xml
 ----------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/
android:orientation="vertical" android:layout_width="fil
<ScrollView android:id="@+id/scrollView1" android:layout_hei
android:layout_width="fill_parent">
</ScrollView>
</LinearLayout>
table_row_columns.xml
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/
android:layout_width="fill_parent" android:layout_height="
<TextView android:layout_height="wrap_content" android:t
<TextView android:layout_width="wrap_content" android:la
</TableRow>

 ----------------------------
table_span_row.xml
 ----------------------------
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/
android:layout_height="wrap_content" android:layout_width=
<LinearLayout android:layout_height="wrap_content" andro
<TextView android:layout_width="wrap_content" androi
<TextView android:id="@+id/textView1" android:layout
</LinearLayout>
</TableRow>

Check a cleaner post snd screenshot at [URL]stackoverflow.com/
questions/6073348/tablerow-span-not-working-for-dynamically-added-
rows[/URL]

P.S. I also welcome advises about how to dynamically
replace views within the ScrollView
android tableview tablerow

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to