[Mono-bugs] [Bug 675810] New: View android:onClick attribute throws method NoSuchMethodException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Mar 1 00:47:40 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=675810

https://bugzilla.novell.com/show_bug.cgi?id=675810#c0


           Summary: View android:onClick attribute throws method
                    NoSuchMethodException
    Classification: Mono
           Product: MonoDroid
           Version: SVN
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Runtime
        AssignedTo: mkestner at novell.com
        ReportedBy: adam.tybor at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20

The android:onClick attribute on views should be wired up to a public method on
the containing method.  Instead it is throwing a java NoSuchMethodException.

Reproducible: Always

Steps to Reproduce:
1. Create a new MonoDroid Application
2. Edit the Main.axml view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<Button  
    android:id="@+id/MyButton"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/Hello"
    android:onClick="MyButton_OnClick"
    />
</LinearLayout>

3. Create an Activity

[Activity(Label = "MonoDroidSandbox", MainLauncher = true)]
    public class Activity1 : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
        }

        public void MyButton_OnClick(View view)
        {
            Log.Verbose("MonoDroidSanbox", "OnClick!");
        }
    }
public void MyButton_OnClick(View view) {
  Log.Verbose("MonoDroid", "My Button Clicked!");
}

4. Run the application and click the button

Actual Results:  
adb logcat

E/AndroidRuntime(  517): FATAL EXCEPTION: main
E/AndroidRuntime(  517): java.lang.IllegalStateException: Could not find a
method MyButton_OnClick(View) in the activity class monodroidsandbox.Activity1
for
onClick handler on view class android.widget.Button with id 'MyButton'
E/AndroidRuntime(  517):        at android.view.View$1.onClick(View.java:2131)
E/AndroidRuntime(  517):        at
android.view.View.performClick(View.java:2485)
E/AndroidRuntime(  517):        at
android.view.View$PerformClick.run(View.java:9080)
E/AndroidRuntime(  517):        at
android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(  517):        at
android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(  517):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  517):        at
android.app.ActivityThread.main(ActivityThread.java:3647)
E/AndroidRuntime(  517):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(  517):        at
java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(  517):        at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(  517):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(  517):        at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime(  517): Caused by: java.lang.NoSuchMethodException:
MyButton_OnClick
E/AndroidRuntime(  517):        at
java.lang.ClassCache.findMethodByName(ClassCache.java:247)
E/AndroidRuntime(  517):        at java.lang.Class.getMethod(Class.java:962)
E/AndroidRuntime(  517):        at android.view.View$1.onClick(View.java:2124)
E/AndroidRuntime(  517):        ... 11 more
W/ActivityManager(   70):   Force finishing activity
MonoDroidSandbox.MonoDroidSandbox/monodroidsandbox.Activity1
W/ActivityManager(   70): Activity pause timeout for HistoryRecord{405186a0
MonoDroidSandbox.MonoDroidSandbox/monodroidsandbox.Activity1}
I/ARMAssembler(   70): generated scanline__00000177:03515104_00001001_00000000
[ 91 ipp] (114 ins) at [0x445db838:0x445dba00] in 1680622 ns
I/Process (  517): Sending signal. PID: 517 SIG: 9

Expected Results:  
adb logcat

V/MonoDroid(   517): My Button Clicked!

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list