Skip to content

xml android:onClick not working #305

Open
@muhammad-naderi

Description

Hi,

when I add this snippet to the activity class to wrap the context, the xml android:onClick does not work.

@Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }

I mean it throws this exception

07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err: java.lang.IllegalStateException: Could not find a method OnDeleteBtnClick(View) in the activity class uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper for onClick handler on view class com.rey.material.widget.FloatingActionButton with id 'optionView'
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.view.View$1.onClick(View.java:3956)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at com.rey.material.widget.RippleManager.run(RippleManager.java:85)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at com.rey.material.widget.RippleManager.onClick(RippleManager.java:79)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.view.View.performClick(View.java:4640)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.view.View$PerformClick.run(View.java:19421)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.os.Handler.handleCallback(Handler.java:733)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.os.Looper.loop(Looper.java:146)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5602)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at dalvik.system.NativeStart.main(Native Method)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err: Caused by: java.lang.NoSuchMethodException: OnDeleteBtnClick [class android.view.View]
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at java.lang.Class.getConstructorOrMethod(Class.java:472)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at java.lang.Class.getMethod(Class.java:857)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:     at android.view.View$1.onClick(View.java:3949)
07-12 18:50:11.150 15984-15984/com.shygunsys.pocketcyber W/System.err:  ... 13 more

somehow wrapping the context prevents the system in looking correct class for onClick method since as soon as I comment the attachBaseContext override, everything start working fine

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions