On Dec 9, 2011, at 12:52 PM, Hernani Delindro wrote: > Hello, I'm still new to Mono for Android, and C# in general, but I would like > some help on how to "translate" the following code to m4a, because I'm > having trouble understanding with how listeners and callbacks are > implemented in m4a. > > webview.SetWebChromeClient(new WebChromeClient() { > public void OnProgressChanged(WebView view, int progress) > { > activity.SetTitle("Loading..."); > activity.SetProgress(progress * 100); > > if(progress == 100) > activity.SetTitle(Resource.String.app_name); > } > });
That is an anonymous inner class, which C# doesn't support. Instead, you need to turn it into a "normal" class (either at top-level or a nested type, doesn't really matter): class WebChromeClientDelegator : WebChromeClient { public Action<WebView, int> ProgressChanged; public override void OnProgressChanged (WebView view, int newProgress) { if (ProgressChanged != null) ProgressChanged (view, newProgress); } } // ... webview.SetWebChromeClient (new WebChromeClientDelegator () { ProgressChanged = (view, progress) => { activity.SetTitle ("Loading..."); activity.SetProgress (progress * 100); if (progress == 100) activity.SetTitle (Resource.String.app_name); }, }); - Jon _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid