Hi,
ich bin grade in die Androidprogrammierung eingestiegen und war dabei eine erste App zu erstellen. Leider bekomme ich dauernd einen Fehler, den ich trotz Google und Forensuche einfach nicht behoben kriege. Die relevante Fehlermeldung von LogCat lautet wie folgt:
Die beiden Abschnitte auf die hier verwiesen wird lauten:
[XML]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@dimen/activity_horizontal_margin"
android:gravity="center"
android
addingBottom="@dimen/activity_vertical_margin"
android
addingLeft="@dimen/activity_horizontal_margin"
android
addingRight="@dimen/activity_horizontal_margin"
android
addingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:layout_centerInParent="false"
android:layout_centerVertical="false"
android:gravity="center"
android:text="@string/beschriftung"
android:textColor="@dimen/activity_horizontal_margin"
android:textSize="20sp" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="@string/start" />
</RelativeLayout>[/XML]
Und die Javaklasse:
Befindet sich dort irgendwo ein offensichtlicher Fehler?
ich bin grade in die Androidprogrammierung eingestiegen und war dabei eine erste App zu erstellen. Leider bekomme ich dauernd einen Fehler, den ich trotz Google und Forensuche einfach nicht behoben kriege. Die relevante Fehlermeldung von LogCat lautet wie folgt:
Code:
12-28 17:00:08.895: E/AndroidRuntime(5450): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.muckenmassaker/com.example.muckenmassaker.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
12-28 17:00:08.895: E/AndroidRuntime(5450): at com.example.muckenmassaker.MainActivity.onCreate(MainActivity.java:16)
[XML]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@dimen/activity_horizontal_margin"
android:gravity="center"
android
android
android
android
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:layout_centerInParent="false"
android:layout_centerVertical="false"
android:gravity="center"
android:text="@string/beschriftung"
android:textColor="@dimen/activity_horizontal_margin"
android:textSize="20sp" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="@string/start" />
</RelativeLayout>[/XML]
Und die Javaklasse:
Java:
package com.example.muckenmassaker;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(this,GameActivity.class));
}
}