有进入下一个意图的错误。
当我点击按钮时,它立刻给了我一个力量。 我想将包解析为摘要onclick方法。
logcat
01-27 22:17:11.826: E/AndroidRuntime(32003): FATAL EXCEPTION: main
01-27 22:17:11.826: E/AndroidRuntime(32003): java.lang.IllegalStateException: Could not find a method summaryClick(View) in the activity class com.example.fuellogproject.ViewAll for onClick handler on view class android.widget.Button with id 'summaryBTN'
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.view.View$1.onClick(View.java:3711)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.view.View.performClick(View.java:4261)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.view.View$PerformClick.run(View.java:17356)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.os.Handler.handleCallback(Handler.java:615)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.os.Handler.dispatchMessage(Handler.java:92)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.os.Looper.loop(Looper.java:137)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.app.ActivityThread.main(ActivityThread.java:4921)
01-27 22:17:11.826: E/AndroidRuntime(32003): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 22:17:11.826: E/AndroidRuntime(32003): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 22:17:11.826: E/AndroidRuntime(32003): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
01-27 22:17:11.826: E/AndroidRuntime(32003): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
01-27 22:17:11.826: E/AndroidRuntime(32003): at dalvik.system.NativeStart.main(Native Method)
01-27 22:17:11.826: E/AndroidRuntime(32003): Caused by: java.lang.NoSuchMethodException: summaryClick [class android.view.View]
01-27 22:17:11.826: E/AndroidRuntime(32003): at java.lang.Class.getConstructorOrMethod(Class.java:460)
01-27 22:17:11.826: E/AndroidRuntime(32003): at java.lang.Class.getMethod(Class.java:915)
01-27 22:17:11.826: E/AndroidRuntime(32003): at android.view.View$1.onClick(View.java:3704)
01-27 22:17:11.826: E/AndroidRuntime(32003): ... 11 more
代码:
public void summaryClick (int arg2)
{
Intent sum = new Intent(this, summary.class);
fuelLogPojo clickedObject = pojoArrayList.get(arg2);
Bundle dataBundle = new Bundle();
dataBundle.putString("clickedID", clickedObject.getid());
dataBundle.putString("clickedDate", clickedObject.getdate());
dataBundle.putString("clickedPrice", clickedObject.getprice());
dataBundle.putString("clickedPump", clickedObject.getpump());
dataBundle.putString("clickedCost", clickedObject.getcost());
dataBundle.putString("clickedOdometer", clickedObject.getodometer());
dataBundle.putString("clickedpreOdometer",
clickedObject.getpreodometer());
dataBundle.putString("clickedFCon", clickedObject.getfcon());
Log.i("FuelLog", "dataBundle " + dataBundle);
// Attach the bundled data to the intent
sum.putExtras(dataBundle);
// Start the Activity
startActivity(sum);
}
答案 0 :(得分:4)
您的方法必须在错误消息中指明签名。 所以将签名更改为:
public void summaryClick(View view)
答案 1 :(得分:4)
您的方法签名错误
更改
public void summaryClick (int arg2)
到
public void summaryClick (View arg2)
你可能有
andorid:onClick="summaryClick"
in xml for button
发表评论
fuelLogPojo clickedObject = pojoArrayList.get(arg2);
View arg2
不是int
。