imoney91
- Forum-Beiträge: 34
09.01.2012, 15:05:13 via Website
09.01.2012 15:05:13 via Website
Hallo Community,
ich hab folgendes Problem. Mit einem ImageButton löse ich in dem Event ein Activity-Aufruf aus, aber aus irgendeinem Grund stürzt es immer ab.
Logcat:
und hier der Aufruf
Bitte um Hilfe
Gruß Nguyen
ich hab folgendes Problem. Mit einem ImageButton löse ich in dem Event ein Activity-Aufruf aus, aber aus irgendeinem Grund stürzt es immer ab.
Logcat:
1101-09 14:58:00.463: E/AndroidRuntime(1125): FATAL EXCEPTION: main
2201-09 14:58:00.463: E/AndroidRuntime(1125): java.lang.RuntimeException: Unable to start activity ComponentInfo{project.app/project.app.AuswahlEins}: java.lang.ClassCastException: android.widget.ImageButton
3301-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
4401-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
5501-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
6601-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
7701-09 14:58:00.463: E/AndroidRuntime(1125): at android.os.Handler.dispatchMessage(Handler.java:99)
8801-09 14:58:00.463: E/AndroidRuntime(1125): at android.os.Looper.loop(Looper.java:143)
9901-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.main(ActivityThread.java:4914)
101001-09 14:58:00.463: E/AndroidRuntime(1125): at java.lang.reflect.Method.invokeNative(Native Method)
111101-09 14:58:00.463: E/AndroidRuntime(1125): at java.lang.reflect.Method.invoke(Method.java:521)
121201-09 14:58:00.463: E/AndroidRuntime(1125): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
131301-09 14:58:00.463: E/AndroidRuntime(1125): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
141401-09 14:58:00.463: E/AndroidRuntime(1125): at dalvik.system.NativeStart.main(Native Method)
151501-09 14:58:00.463: E/AndroidRuntime(1125): Caused by: java.lang.ClassCastException: android.widget.ImageButton
161601-09 14:58:00.463: E/AndroidRuntime(1125): at project.app.AuswahlEins.onCreate(AuswahlEins.java:21)
171701-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
181801-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
191901-09 14:58:00.463: E/AndroidRuntime(1125): ... 11 more
2201-09 14:58:00.463: E/AndroidRuntime(1125): java.lang.RuntimeException: Unable to start activity ComponentInfo{project.app/project.app.AuswahlEins}: java.lang.ClassCastException: android.widget.ImageButton
3301-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
4401-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
5501-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
6601-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
7701-09 14:58:00.463: E/AndroidRuntime(1125): at android.os.Handler.dispatchMessage(Handler.java:99)
8801-09 14:58:00.463: E/AndroidRuntime(1125): at android.os.Looper.loop(Looper.java:143)
9901-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.main(ActivityThread.java:4914)
101001-09 14:58:00.463: E/AndroidRuntime(1125): at java.lang.reflect.Method.invokeNative(Native Method)
111101-09 14:58:00.463: E/AndroidRuntime(1125): at java.lang.reflect.Method.invoke(Method.java:521)
121201-09 14:58:00.463: E/AndroidRuntime(1125): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
131301-09 14:58:00.463: E/AndroidRuntime(1125): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
141401-09 14:58:00.463: E/AndroidRuntime(1125): at dalvik.system.NativeStart.main(Native Method)
151501-09 14:58:00.463: E/AndroidRuntime(1125): Caused by: java.lang.ClassCastException: android.widget.ImageButton
161601-09 14:58:00.463: E/AndroidRuntime(1125): at project.app.AuswahlEins.onCreate(AuswahlEins.java:21)
171701-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
181801-09 14:58:00.463: E/AndroidRuntime(1125): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
191901-09 14:58:00.463: E/AndroidRuntime(1125): ... 11 more
und hier der Aufruf
11package project.app;
22
33import android.app.Activity;
44import android.content.Intent;
55import android.os.Bundle;
66import android.view.View;
77import android.widget.Button;
88
99public class AuswahlEins extends Activity {
1010 /** Called when the activity is first created. */
1111 @Override
1212 public void onCreate(Bundle savedInstanceState) {
1313 super.onCreate(savedInstanceState);
1414 setContentView(R.layout.auswahleins);
1515
1616
1717
1818 //Button Event
1919
2020 //auswahleins ok button
2121 Button okButton = (Button)findViewById(R.id.imageButton1);
2222 okButton.setOnClickListener(new View.OnClickListener(){
2323 @Override
2424 public void onClick(View v) {
2525 Intent in1 = new Intent(AuswahlEins.this,AuswahlZwei.class);
2626 startActivity(in1);
2727 }
2828 } );
2929
3030 }
3131}
22
33import android.app.Activity;
44import android.content.Intent;
55import android.os.Bundle;
66import android.view.View;
77import android.widget.Button;
88
99public class AuswahlEins extends Activity {
1010 /** Called when the activity is first created. */
1111 @Override
1212 public void onCreate(Bundle savedInstanceState) {
1313 super.onCreate(savedInstanceState);
1414 setContentView(R.layout.auswahleins);
1515
1616
1717
1818 //Button Event
1919
2020 //auswahleins ok button
2121 Button okButton = (Button)findViewById(R.id.imageButton1);
2222 okButton.setOnClickListener(new View.OnClickListener(){
2323 @Override
2424 public void onClick(View v) {
2525 Intent in1 = new Intent(AuswahlEins.this,AuswahlZwei.class);
2626 startActivity(in1);
2727 }
2828 } );
2929
3030 }
3131}
Bitte um Hilfe
Gruß Nguyen
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.