Okay, sieht jetzt so aus :
1@Override
2 public void onClick(View v) {
3 int tag = (Integer) fish.getTag(R.string.FISH_TAG);
4
5 switch(tag) {
6 case 25:
7 caughtfish25++;
8 scoreopps();
9 playplace.removeView(fish25);
10 case 100:
11 caughtfish100++;
12 scoreopps();
13 playplace.removeView(fish100);
14 case 500:
15 caughtfish500++;
16 scoreopps();
17 playplace.removeView(fish500);
18 case 10:
19 time = time +10;
20 refreshscreen();
21 playplace.removeView(fishadd10);
22 case 11:
23 time = time -10;
24 refreshscreen();
25 playplace.removeView(fishdeducts10);
26 case 12:
27 time = 0;
28 refreshscreen();
29 playplace.removeView(fishsetzero);
30 default:
31 System.out.println("Fehler 311");
32
33 }
Leider bekommt ich immer noch :
103-26 15:08:09.469: E/AndroidRuntime(24805): FATAL EXCEPTION: main
203-26 15:08:09.469: E/AndroidRuntime(24805): java.lang.NullPointerException
303-26 15:08:09.469: E/AndroidRuntime(24805): at com.togames.pointyfish.GameActivity.onClick(GameActivity.java:586)
403-26 15:08:09.469: E/AndroidRuntime(24805): at android.view.View.performClick(View.java:4247)
503-26 15:08:09.469: E/AndroidRuntime(24805): at android.view.View$PerformClick.run(View.java:17492)
603-26 15:08:09.469: E/AndroidRuntime(24805): at android.os.Handler.handleCallback(Handler.java:725)
703-26 15:08:09.469: E/AndroidRuntime(24805): at android.os.Handler.dispatchMessage(Handler.java:92)
803-26 15:08:09.469: E/AndroidRuntime(24805): at android.os.Looper.loop(Looper.java:153)
903-26 15:08:09.469: E/AndroidRuntime(24805): at android.app.ActivityThread.main(ActivityThread.java:5330)
1003-26 15:08:09.469: E/AndroidRuntime(24805): at java.lang.reflect.Method.invokeNative(Native Method)
1103-26 15:08:09.469: E/AndroidRuntime(24805): at java.lang.reflect.Method.invoke(Method.java:511)
1203-26 15:08:09.469: E/AndroidRuntime(24805): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
1303-26 15:08:09.469: E/AndroidRuntime(24805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
1403-26 15:08:09.469: E/AndroidRuntime(24805): at dalvik.system.NativeStart.main(Native Method)
Ich glaube das ich den Fehler beim setzten des Tags gemacht habe, vllt sieht ihr ja da was:
1fish.setTag(R.string.FISH_TAG, 25);
Dieser Code ist bei allen Fischen gleich außer natürlich der Wert.