зеркало из https://github.com/mono/mail-archives.git
136 строки
3.9 KiB
HTML
136 строки
3.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [mono-android] How to use OnProgressChanged in m4a?
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20How%20to%20use%20OnProgressChanged%20in%20m4a%3F&In-Reply-To=1323453123349-5062534.post%40n5.nabble.com">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="007709.html">
|
|
<LINK REL="Next" HREF="007714.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[mono-android] How to use OnProgressChanged in m4a?</H1>
|
|
<B>Jonathan Pryor</B>
|
|
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20How%20to%20use%20OnProgressChanged%20in%20m4a%3F&In-Reply-To=1323453123349-5062534.post%40n5.nabble.com"
|
|
TITLE="[mono-android] How to use OnProgressChanged in m4a?">jonp at xamarin.com
|
|
</A><BR>
|
|
<I>Fri Dec 9 14:23:43 EST 2011</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="007709.html">[mono-android] How to use OnProgressChanged in m4a?
|
|
</A></li>
|
|
<LI>Next message: <A HREF="007714.html">[mono-android] How to use OnProgressChanged in m4a?
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#7711">[ date ]</a>
|
|
<a href="thread.html#7711">[ thread ]</a>
|
|
<a href="subject.html#7711">[ subject ]</a>
|
|
<a href="author.html#7711">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>On Dec 9, 2011, at 12:52 PM, Hernani Delindro wrote:
|
|
><i> Hello, I'm still new to Mono for Android, and C# in general, but I would like
|
|
</I>><i> some help on how to "translate" the following code to m4a, because I'm
|
|
</I>><i> having trouble understanding with how listeners and callbacks are
|
|
</I>><i> implemented in m4a.
|
|
</I>><i>
|
|
</I>><i> webview.SetWebChromeClient(new WebChromeClient() {
|
|
</I>><i> public void OnProgressChanged(WebView view, int progress)
|
|
</I>><i> {
|
|
</I>><i> activity.SetTitle("Loading...");
|
|
</I>><i> activity.SetProgress(progress * 100);
|
|
</I>><i>
|
|
</I>><i> if(progress == 100)
|
|
</I>><i> activity.SetTitle(Resource.String.app_name);
|
|
</I>><i> }
|
|
</I>><i> });
|
|
</I>
|
|
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
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="007709.html">[mono-android] How to use OnProgressChanged in m4a?
|
|
</A></li>
|
|
<LI>Next message: <A HREF="007714.html">[mono-android] How to use OnProgressChanged in m4a?
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#7711">[ date ]</a>
|
|
<a href="thread.html#7711">[ thread ]</a>
|
|
<a href="subject.html#7711">[ subject ]</a>
|
|
<a href="author.html#7711">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/monodroid">More information about the Monodroid
|
|
mailing list</a><br>
|
|
</body></html>
|