Chloe
Chloe

Reputation: 149

unable to go to next intent, force close error

having error for getting into next intent.

When I click on the button, it gave me a force close immediately. I wanted to parse the bundle into the summary onclick method.

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

code:

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);


    }

Upvotes: 0

Views: 95

Answers (2)

Raghunandan
Raghunandan

Reputation: 133560

Your method signature is wrong

Change

 public void summaryClick (int arg2)

to

 public void summaryClick (View arg2)

You probably have

 andorid:onClick="summaryClick" 

in xml for button

To the comment

 fuelLogPojo clickedObject = pojoArrayList.get(arg2);

View arg2 is not int.

Upvotes: 4

Ben Weiss
Ben Weiss

Reputation: 17922

Your method must have the signature indicated in the error message. So change the signature to:

public void summaryClick(View view)

Upvotes: 4

Related Questions