2

I had a strange problem. I am creating a table by inflating the table row like this

TableLayout table = (TableLayout) findViewById(R.id.tablelay);
LayoutInflater inflater = getLayoutInflater();

for (int j = 0; j < limit ; j++) {

    TableRow row = (TableRow) inflater.inflate(R.layout.row_details, table, false);

     t1 = (TextView) row.findViewById(R.id.firstTxt);
     t1.setText(""+ firstData[j]);

     t2 = (TextView) row.findViewById(R.id.secondTxt);
     t2.setText(""+ secondData[j]);
     table.addView(row, new TableRow.LayoutParams(
                    TableRow.LayoutParams.FILL_PARENT,
                    TableRow.LayoutParams.WRAP_CONTENT)); 
 }

The "row_details.xml" is a layout contains two textviews ("firstTxt" ,"secondTxt"). I am able to add data and is displayed on the screen.

The problems comes when i rotate it to landscape mode, then all the data is lost. Initially i thought this may due to orientation problem (ie data loss due to reloading the activity).

But first time when i load the activity in landscape mode then no data is displayed and now rotating to portrait mode shows the data. So i think this is due to inflating in landscape mode.

Observation :- portrait view shows data and landscape view shows no data

how do i solve this problem ?....thanks in advance.

droid kid
  • 7,569
  • 2
  • 32
  • 37

2 Answers2

0

Try looking at this like from android documentation:

http://developer.android.com/guide/topics/resources/runtime-changes.html

Prashant Lakhlani
  • 5,758
  • 5
  • 25
  • 39
0

add in menifest activity tag configChange="orientation"

Shailendra Singh Rajawat
  • 8,172
  • 3
  • 35
  • 40
  • noo....when i load the activity in landscape mode then the data is not shown. here i am not changing the orientation – droid kid Nov 23 '11 at 13:15