S
Son Goku
Ambitioniertes Mitglied
- 5
Hallo
Ich habe ein Layout was wie folgt aufgebaut ist:
(tabelle.xml)
Folgedes Layout wird includiert:
(neue_zeile.xml)
Nun möchte ich zur Laufzeit neue Zeilen hinzufügen zu der einen bisher includierten.
Dazu habe ich folgenden Java-Code:
In der Zeile, wo das addView steht, bekomme ich aber immer die Meldung "Source not found".
Was mache ich falsch? Ist das überhaupt während der Laufzeit möglich?
Wie kann ich evtl. anders vor gehen?
Danke für eure Hilfe.
Viele Grüße
Son Goku
Ich habe ein Layout was wie folgt aufgebaut ist:
(tabelle.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TableRow
android:paddingLeft="15px"
android:id="@+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:text="@string/textSpalte1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/textView1">
</TextView>
<TextView
android:text="@string/textSpalte2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/textView2">
</TextView>
</TableRow>
<include android:layout_height="wrap_content" layout="@layout/neue_zeile" android:id="@+id/include1" android:layout_width="wrap_content"></include>
</TableLayout>
</LinearLayout>
(neue_zeile.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/neueZeile1"
style="@style/style_neue_zeile">
<EditText
android:id="@+id/editText1"
style="@style/style_spalte1"
android:inputType="number">
</EditText>
<EditText
android:id="@+id/editText2"
style="@style/style_spalte2">
</EditText>
</TableRow>
Dazu habe ich folgenden Java-Code:
Code:
protected void addNeueZeile() {
TableLayout table = (TableLayout) findViewById(R.id.tableLayout1);
TableRow tr = (TableRow) findViewById(R.id.neueZeile1);
table.addView(tr);
}
Was mache ich falsch? Ist das überhaupt während der Laufzeit möglich?
Wie kann ich evtl. anders vor gehen?
Danke für eure Hilfe.
Viele Grüße
Son Goku