| |||||||
Das Thema "Problem mit dem Includieren eines Layouts während der Laufzeit" befindet sich unter Android App Entwicklung auf Android-Hilfe.de.
|
| | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Neuer Benutzer Registriert seit: 07.12.2010
Beiträge: 26
Abgegebene Danke: 2
Erhielt 2 Danke für 2 Beiträge
| 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 |
| | |
| | #2 (permalink) |
| Android-Hilfe.de Mitglied |
Halllo Son Goku, mit "findViewById(int)" kannst du nur View finden, die bereits in deinem Content geladen sind. Wenn du neue Views aus anderen xml-Dateien laden adden willst, brauchst du den LayoutInflater. regards |
| | |
| Folgender Benutzer bedankt sich bei Neeldarax für diesen Beitrag: | Son Goku (27.06.2011) |
![]() |
|
| Themen-Optionen | |
| Ansicht | |
| |
| ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Standby während eines Telefonats verhindern | TimFranke | Sony Ericsson Xperia X10 Mini / Mini Pro | 11 | 21.01.2011 22:52 |
| Keine Datenverbindung während eines Telefonates? | Omerta | Motorola Milestone Forum | 13 | 02.09.2010 20:35 |
| Während dem Laden wackelt der Bildschirm beim Scrolling und Halten | cybercrash | Motorola Milestone Forum | 1 | 21.12.2009 00:14 |
| Displaysperre während eines Telefonats | kitagua | Samsung Galaxy (I7500) Forum | 1 | 01.10.2009 11:16 |