-1

I have three activity in my application. In my second activity I have some elements that are made dynamically by user. When I click on device back button or go to third activity, second activity restarts. Why? first activity:

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second );
 }

and in second activity i creat element:

       final  TableLayout tbl=(TableLayout)findViewById(R.id.tblProduct);
   TableRow row=new TableRow(this);
   EditText ed=new EditText(this);
   ed.setLayoutParams( new TableRow.LayoutParams( 0, android.view.ViewGroup.LayoutParams.WRAP_CONTENT,.10f ) );
   row.addView(ed);
   tbl.addView(row);

when i back to first activity the created element be cleared.

4

1 回答 1

0

由于元素是动态生成的,它们不会存储在任何地方您可以尝试在方法中存储元素数据并在方法onPause()中恢复它们onResume()

于 2013-06-12T09:30:17.093 回答