R
RyuZz
Neues Mitglied
- 0
Hallo Leute,
seit einigen Tagen befasse ich mich nun mit der App-Entwicklung für Android und bin mittlerweile am verzweifeln.
Ich möchte Images in ein LinearLayout(horizontal) einfügen, welches sich in einer horizontalScrollView befindet.
So mein Code:
MainActivity.java
fragment_main.xml
Wenn ich nun die App auf mein Handy lade bekomme ich folgende Fehlermeldung:
Was übersehe ich, bzw. was habe ich falsch gemacht?
seit einigen Tagen befasse ich mich nun mit der App-Entwicklung für Android und bin mittlerweile am verzweifeln.
Ich möchte Images in ein LinearLayout(horizontal) einfügen, welches sich in einer horizontalScrollView befindet.
So mein Code:
MainActivity.java
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout sv = (LinearLayout) findViewById (R.id.linearLayoutimages1);
for (int i=1 ; i<=3; i++){
String uri = "drawable/testi" + i;
int imageResource = getResources().getIdentifier(uri, null, getPackageName());
ImageView iv = new ImageView (this);
iv.setBackgroundResource (imageResource);
sv.addView(iv);
}
Code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.xproject.MainActivity$PlaceholderFragment" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/linearLayoutimages1"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</HorizontalScrollView>
</TableRow>
</TableLayout>
</ScrollView>

Was übersehe ich, bzw. was habe ich falsch gemacht?