Hey ho,
also ich wollte mal zum "lernen" eine kleine App schreiben, die mir aus einem Betrag (double) die Steuern berechnet.
Doch irgendwas scheint nun kaputt zu sein, da ich die App nicht mehr starten kann.
Keine Ahnung was ich geändert habe -.-
Hier mal der Source:
Java
package de.thunderfrog.nettorechner2013;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.*;
public class MainActivity extends Activity {
private EditText werteAnzeige;
private RadioButton neunzehn;
private RadioButton sieben;
private double betrag;
private double ergebniss;
private double steuer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button berechnen = (Button)findViewById(R.id.berechnen);
werteAnzeige = (EditText)findViewById(R.id.netto);
neunzehn = (RadioButton)findViewById(R.id.neunzehn);
sieben = (RadioButton)findViewById(R.id.sieben);
steuer = 0.00;
ergebniss = 0.00;
berechnen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(neunzehn.isChecked()){
steuer = 1.19;
ergebniss = betrag * steuer;
String output = String.valueOf(ergebniss);
werteAnzeige.append(output);
}else if (sieben.isChecked()){
steuer = 1.07;
ergebniss = betrag * steuer;
String output = String.valueOf(ergebniss);
werteAnzeige.append(output);
}
}
});
}
}
Alles anzeigen
Passend dazu der LogCat
Code
06-26 18:07:12.733: E/Trace(12812): error opening trace file: No such file or directory (2)
06-26 18:07:12.843: W/dalvikvm(12812): threadid=1: thread exiting with uncaught exception (group=0x41469540)
06-26 18:07:12.853: D/Process(12812): killProcess, pid=12812
06-26 18:07:12.853: D/Process(12812): dalvik.system.VMStack.getThreadStackTrace(Native Method)
06-26 18:07:12.853: D/Process(12812): java.lang.Thread.getStackTrace(Thread.java:599)
06-26 18:07:12.853: D/Process(12812): android.os.Process.killProcess(Process.java:951)
06-26 18:07:12.853: D/Process(12812): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
06-26 18:07:12.853: D/Process(12812): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
06-26 18:07:12.853: D/Process(12812): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
06-26 18:07:25.777: E/Trace(12910): error opening trace file: No such file or directory (2)
06-26 18:07:25.847: W/dalvikvm(12910): threadid=1: thread exiting with uncaught exception (group=0x41469540)
06-26 18:07:25.847: E/AndroidRuntime(12910): FATAL EXCEPTION: main
06-26 18:07:25.847: E/AndroidRuntime(12910): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.thunderfrog.nettorechner2013/de.thunderfrog.nettorechner2013.MainActivity}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2368)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.ActivityThread.access$600(ActivityThread.java:151)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.os.Looper.loop(Looper.java:155)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.ActivityThread.main(ActivityThread.java:5536)
06-26 18:07:25.847: E/AndroidRuntime(12910): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 18:07:25.847: E/AndroidRuntime(12910): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 18:07:25.847: E/AndroidRuntime(12910): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1074)
06-26 18:07:25.847: E/AndroidRuntime(12910): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841)
06-26 18:07:25.847: E/AndroidRuntime(12910): at dalvik.system.NativeStart.main(Native Method)
06-26 18:07:25.847: E/AndroidRuntime(12910): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
06-26 18:07:25.847: E/AndroidRuntime(12910): at de.thunderfrog.nettorechner2013.MainActivity.onCreate(MainActivity.java:25)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.Activity.performCreate(Activity.java:5066)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
06-26 18:07:25.847: E/AndroidRuntime(12910): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
06-26 18:07:25.847: E/AndroidRuntime(12910): ... 11 more
Alles anzeigen
Bin eigentlich keiner der direkt rum heult, aber ich finde den fehler einfach nicht ...
Hoffentlich hat jemand ein Tipp / Lösung für mich.
Gruß und Danke schon mal.