根据其它的activity中的值如何创建和保存一个新的tableRow?

我使用 putExtra 从Activity A中发送TextViews,然后再发送到TableRow 中的Activity B里边。接下来我可以使用SavePreferences来保存view。现在的问题是我可以在Activity A中放入一些entries,然后发送到Activity B,如何在 Activity B中创建一个新的TableRow,还不毁坏之前保存的那个?

TableLayout01 = (TableLayout) findViewById(R.id.TableLayout01);
    TableRow tableRow1 = new TableRow(this);
Intent in = getIntent();
    if (in.getCharSequenceExtra("blah") != null) {
        final TextView resultTextView = new TextView(this);
        resultTextView.setText(in.getCharSequenceExtra("blah"));
        tableRow1.addView(resultTextView);
Intent is = getIntent();
    if (is.getCharSequenceExtra("no") != null) {
        final TextView date = new TextView(this);
        date.setText(is.getCharSequenceExtra("no"));
        tableRow1.addView(date);
TableLayout01.addView(tableRow1, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,1.0f));

你可以在活动B中按照以下步骤创建并保存一个新的TableRow:

  • 从Intent中接收数据,并将它们转换为适当的类型(例如CharSequence)。
  • 使用这些数据来创建新的TextViews。
  • 将新创建的TextViews添加到新的TableRow中。
  • 将新的TableRow添加到TableLayout中。

例如:

Intent in = getIntent();
CharSequence data1 = in.getCharSequenceExtra("blah");
CharSequence data2 = in.getCharSequenceExtra("no");

TableLayout tableLayout = (TableLayout) findViewById(R.id.TableLayout01);
TableRow tableRow = new TableRow(this);

TextView textView1 = new TextView(this);
textView1.setText(data1);
tableRow.addView(textView1);

TextView textView2 = new TextView(this);
textView2.setText(data2);
tableRow.addView(textView2);

tableLayout.addView(tableRow, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));

这样就可以在活动B中创建并添加新的TableRow,而不会毁坏之前保存的TableRow。