Y
YouKnowNow
Neues Mitglied
- 0
Hey Leute ich hab ne kleine App geschrieben aber irgendwie starten sie aber sobald ich auf ein Button drücke setht da ...reagiert nicht Hier der Code:
Lektionen. java hier stürtzt es ab:
package com.youknownow.lateinfelixuebersetzunen;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Lektionen extends AppCompatActivity {
Button btn1 ;
Button btn2 ;
Button btn3 ;
Button btn4 ;
Button btn5 ;
Button btn6 ;
Button btn7 ;
Button btn8 ;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lektionen);
btn1 = (Button)findViewById(R.id.L2_10);
btn2 = (Button)findViewById(R.id.L11_20);
btn3 = (Button)findViewById(R.id.L21_30);
btn4 = (Button)findViewById(R.id.L31_40);
btn5 = (Button)findViewById(R.id.L41_50);
btn6 = (Button)findViewById(R.id.L51_60);
btn7 = (Button)findViewById(R.id.L61_70);
btn8 = (Button)findViewById(R.id.L75);
btn1.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View a) {
startActivity(new Intent(Lektionen.this,Lektion0.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View b) {
startActivity(new Intent(Lektionen.this,Lektion1.class));
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View c) {
startActivity(new Intent(Lektionen.this,Lektion2.class));
}
});
btn4.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View d) {
startActivity(new Intent(Lektionen.this,Lektion3.class));
}
});
btn5.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View e) {
startActivity(new Intent(Lektionen.this,Lektion4.class));
}
});
btn6.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View f) {
startActivity(new Intent(Lektionen.this,Lektion5.class));
}
});
btn7.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View h) {
startActivity(new Intent(Lektionen.this,Lektion6.class));
}
});
btn8.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View i) {
startActivity(new Intent(Lektionen.this,Lektion7.class));
}
});
}
}
aktivity_lektionen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context="com.youknownow.lateinfelixuebersetzunen.Lektionen">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 2-10"
android:id="@+id/L2_10"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 11-20"
android:id="@+id/L11_20"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 21-30"
android:id="@+id/L21_30"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 31-40"
android:id="@+id/L31_40"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 41-50"
android:id="@+id/L41_50"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="250dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 51-60"
android:id="@+id/L51_60"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 61-70"
android:id="@+id/L61_70"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="350dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 75"
android:id="@+id/L75"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="400dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lektionen:"
android:id="@+id/TV"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/D"
android:id="@+id/TVD"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Lektionen. java hier stürtzt es ab:
package com.youknownow.lateinfelixuebersetzunen;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Lektionen extends AppCompatActivity {
Button btn1 ;
Button btn2 ;
Button btn3 ;
Button btn4 ;
Button btn5 ;
Button btn6 ;
Button btn7 ;
Button btn8 ;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lektionen);
btn1 = (Button)findViewById(R.id.L2_10);
btn2 = (Button)findViewById(R.id.L11_20);
btn3 = (Button)findViewById(R.id.L21_30);
btn4 = (Button)findViewById(R.id.L31_40);
btn5 = (Button)findViewById(R.id.L41_50);
btn6 = (Button)findViewById(R.id.L51_60);
btn7 = (Button)findViewById(R.id.L61_70);
btn8 = (Button)findViewById(R.id.L75);
btn1.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View a) {
startActivity(new Intent(Lektionen.this,Lektion0.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View b) {
startActivity(new Intent(Lektionen.this,Lektion1.class));
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View c) {
startActivity(new Intent(Lektionen.this,Lektion2.class));
}
});
btn4.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View d) {
startActivity(new Intent(Lektionen.this,Lektion3.class));
}
});
btn5.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View e) {
startActivity(new Intent(Lektionen.this,Lektion4.class));
}
});
btn6.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View f) {
startActivity(new Intent(Lektionen.this,Lektion5.class));
}
});
btn7.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View h) {
startActivity(new Intent(Lektionen.this,Lektion6.class));
}
});
btn8.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View i) {
startActivity(new Intent(Lektionen.this,Lektion7.class));
}
});
}
}
aktivity_lektionen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context="com.youknownow.lateinfelixuebersetzunen.Lektionen">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 2-10"
android:id="@+id/L2_10"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 11-20"
android:id="@+id/L11_20"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 21-30"
android:id="@+id/L21_30"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 31-40"
android:id="@+id/L31_40"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 41-50"
android:id="@+id/L41_50"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="250dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 51-60"
android:id="@+id/L51_60"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="300dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 61-70"
android:id="@+id/L61_70"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="350dp" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lektion 75"
android:id="@+id/L75"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="400dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lektionen:"
android:id="@+id/TV"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/D"
android:id="@+id/TVD"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>