我在這裏有問題,因爲當我看到計算器代碼的地方,並以某種方式使用它時,應用程序總是強制關閉,當我開始鍵入數字。幫幫我?自動關閉?
public void onClickListener8(View v)
{
vibrator.vibrate(30);
if(press=='=')
{
onClickListenerReset(buttonClear);
}
eight=(String)button8.getText();
sum=sum+eight;
editText.setText(sum);
}
04-17 15:38:23.110: E/AndroidRuntime(678): FATAL EXCEPTION: main
04-17 15:38:23.110: E/AndroidRuntime(678): java.lang.IllegalStateException: Could not execute method of the activity
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View$1.onClick(View.java:2144)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View.performClick(View.java:2485)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View$PerformClick.run(View.java:9080)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Handler.handleCallback(Handler.java:587)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:123)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:507)
04-17 15:38:23.110: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-17 15:38:23.110: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-17 15:38:23.110: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678): Caused by: java.lang.reflect.InvocationTargetException
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:507)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View$1.onClick(View.java:2139)
04-17 15:38:23.110: E/AndroidRuntime(678): ... 11 more
04-17 15:38:23.110: E/AndroidRuntime(678): Caused by: java.lang.SecurityException: Requires VIBRATE permission
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Parcel.readException(Parcel.java:1322)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Parcel.readException(Parcel.java:1276)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.IVibratorService$Stub$Proxy.vibrate(IVibratorService.java:106)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Vibrator.vibrate(Vibrator.java:52)
04-17 15:38:23.110: E/AndroidRuntime(678): at com.mypackage.Calculator.onClickListener8(Calculator.java:232)
04-17 15:38:23.110: E/AndroidRuntime(678): ... 14 more
讓你的「亞行logcat」輸出的副本,並張貼在這裏,你的應用程序有一個bug ...... – 2012-04-17 15:35:21