Hi,

I have an app that includes two TableLayouts whose rows are filled in 
dynamically. Whenever I rotate the device, the rows are cleared for both 
tables. This only happens with the tables, not with other views, like 
TextViews. The relevant XML and Java code are as follows:

*play.xml:*

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView android:id="@+id/new_guess_label"
        android:layout_alignParentLeft="true"
android:layout_below="@id/my_secret_word_text"
    android:textStyle="bold"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/new_guess"/>
 <EditText android:id="@+id/new_guess_text"
    android:layout_toRightOf="@id/new_guess_label"
android:layout_below="@id/my_secret_word_text"
    android:singleLine="true"
    android:capitalize="none"
    android:maxLength="5"
    android:maxEms="5"
    android:layout_width="100dp"
    android:layout_height="wrap_content"/>
    <TextView android:id="@+id/your_guesses"
        android:text="@string/your_guesses"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/new_guess_text"
        android:layout_width="wrap_content"
        android:textColor="#00ff00"
        android:layout_height="wrap_content" />
        
    <TextView android:id="@+id/their_guesses"
        android:text="@string/their_guesses"
        android:layout_below="@id/new_guess_text"
        android:layout_alignParentRight="true"
        android:textColor="#ff0000"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android";
    android:id="@+id/my_scroller"
    android:layout_alignParentLeft="true"
    android:layout_below="@id/your_guesses"
    android:layout_width="wrap_content"
    android:layout_height="180dp" >

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android";
        android:id="@+id/my_guesses"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/your_guesses"
        android:lines="4"
        android:keepScreenOn="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:shrinkColumns="*">
    </TableLayout>

   </ScrollView>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android";
    android:id="@+id/his_scroller"
    android:layout_alignParentRight="true"
    android:layout_below="@id/their_guesses"
    android:layout_width="wrap_content"
    android:layout_height="180dp" >
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android";
        android:id="@+id/his_guesses"
        android:layout_alignParentRight="true"
        android:layout_below="@id/their_guesses"
        android:lines="4"
        android:keepScreenOn="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:shrinkColumns="*">
        
    </TableLayout>
    </ScrollView>
</RelativeLayout>

*PlayActivity.java: *

@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); 
setContentView(R.layout.play); 
.
.
.
my_guesses = (TableLayout) findViewById(R.id.my_guesses); 
.
.
.
tr = new TableRow(context); tr.setLayoutParams(new LayoutParams( 
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); word_view = new 
TextView(context); word_view.setTextColor(Color.BLACK); 
word_view.setText(guess); tr.addView(word_view); count_view = new 
TextView(context); count_view.setTextColor(Color.BLACK); 
count_view.setText(String.valueOf(match_count)); tr.addView(count_view); 
my_guesses.addView(tr, new TableLayout.LayoutParams( 
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

Any ideas would be appreciated.

Bob

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

Reply via email to