mail-archives/monodroid/2010-November/001793.html

86 строки
3.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Monodroid] opening a new activity
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=%5BMonodroid%5D%20opening%20a%20new%20activity&In-Reply-To=AANLkTi%3DM7RY6K7ASrHZ2j3wQj6Zscw9Y7%2B8cFcP%2BaWtH%40mail.gmail.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="001782.html">
<LINK REL="Next" HREF="001788.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Monodroid] opening a new activity</H1>
<B>Jonathan Pryor</B>
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=%5BMonodroid%5D%20opening%20a%20new%20activity&In-Reply-To=AANLkTi%3DM7RY6K7ASrHZ2j3wQj6Zscw9Y7%2B8cFcP%2BaWtH%40mail.gmail.com"
TITLE="[Monodroid] opening a new activity">jpryor at novell.com
</A><BR>
<I>Mon Nov 22 09:42:18 EST 2010</I>
<P><UL>
<LI>Previous message: <A HREF="001782.html">[Monodroid] opening a new activity
</A></li>
<LI>Next message: <A HREF="001788.html">[Monodroid] Java.Lang.Integer to int
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#1793">[ date ]</a>
<a href="thread.html#1793">[ thread ]</a>
<a href="subject.html#1793">[ subject ]</a>
<a href="author.html#1793">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>On Sun, 2010-11-21 at 21:28 -0500, Daniel Lyonnais wrote:
BTW, this:
&gt;<i>
</I>&gt;<i> StartActivity(new Intent(this.BaseContext, new MyActivityClass().Class));
</I> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
is wasteful and should be avoided if possible.
You're creating a new C#-side and Java-side object only to obtain the
Class instance, then you toss both instances away (adding GC overhead,
increasing memory use, etc.), especially when there's a
Intent(Context,Type) constructor [0], allowing:
new Intent (this.BaseContext, typeof(MyActivityClass));
- Jon
[0]
<A HREF="http://docs.monodroid.net/index.aspx?link=C:Android.Content.Intent(Android.Content.Context,System.Type">http://docs.monodroid.net/index.aspx?link=C:Android.Content.Intent(Android.Content.Context,System.Type</A>)
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="001782.html">[Monodroid] opening a new activity
</A></li>
<LI>Next message: <A HREF="001788.html">[Monodroid] Java.Lang.Integer to int
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#1793">[ date ]</a>
<a href="thread.html#1793">[ thread ]</a>
<a href="subject.html#1793">[ subject ]</a>
<a href="author.html#1793">[ 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>