C
Crosaider
Fortgeschrittenes Mitglied
- 11
Hallo @ all
Ich schreibe gerade an einem App, wo ich Itemes einer HorizontalScrollView dynamisch hinzufügen möchte. Mein Layout von der HorizontalScrollView sieht so aus:
Nun habe ich so versucht ein Item der Liste hinzuzufügen:
Bei sv.addView(tv); tritt allerdings ein Fehler auf und das App stürzt ab. Woran kann das liegen? Was habe ich falsch gemacht?
Viele Grüße
Crosaider
Ich schreibe gerade an einem App, wo ich Itemes einer HorizontalScrollView dynamisch hinzufügen möchte. Mein Layout von der HorizontalScrollView sieht so aus:
HTML:
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/imageView1"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/ScrollViewLayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="fill_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/TextView02"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="@string/note"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/TextView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/trennwand_vertikal" />
</LinearLayout>
</HorizontalScrollView>
Code:
LinearLayout sv = (LinearLayout) findViewById(R.id.ScrollViewLayout);
TextView tv = new TextView(this);
tv.setText("Test");
sv.addView(tv);
Viele Grüße
Crosaider