[mono-android] Monodroid Digest, Vol 8, Issue 103

armink 383016632 at qq.com
Tue Mar 22 22:53:56 EDT 2011


Re: Contents of Monodroid digest 
 
 
------------------ Original ------------------
From:  "monodroid-request"<monodroid-request at lists.ximian.com>;
Date:  Wed, Mar 23, 2011 10:19 AM
To:  "monodroid"<monodroid at lists.ximian.com>; 

Subject:  Monodroid Digest, Vol 8, Issue 103

 
 Send Monodroid mailing list submissions to
	monodroid at lists.ximian.com

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.ximian.com/mailman/listinfo/monodroid
or, via email, send a message with subject or body 'help' to
	monodroid-request at lists.ximian.com

You can reach the person managing the list at
	monodroid-owner at lists.ximian.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Monodroid digest..."


Today's Topics:

   1. Re: Monodroid Digest, Vol 8, Issue 84 ( armink )


----------------------------------------------------------------------

Message: 1
Date: Wed, 23 Mar 2011 10:11:38 +0800
From: " armink " <383016632 at qq.com>
Subject: Re: [mono-android] Monodroid Digest, Vol 8, Issue 84
To: " monodroid " <monodroid at lists.ximian.com>
Message-ID: <tencent_54B7ED95712413A64A34F1BE at qq.com>
Content-Type: text/plain; charset="iso-8859-1"

wocaca 
 
 
------------------ Original ------------------
From:  "monodroid-request"<monodroid-request at lists.ximian.com>;
Date:  Sun, Mar 20, 2011 01:44 AM
To:  "monodroid"<monodroid at lists.ximian.com>; 

Subject:  Monodroid Digest, Vol 8, Issue 84

 
 Send Monodroid mailing list submissions to
	monodroid at lists.ximian.com

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.ximian.com/mailman/listinfo/monodroid
or, via email, send a message with subject or body 'help' to
	monodroid-request at lists.ximian.com

You can reach the person managing the list at
	monodroid-owner at lists.ximian.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Monodroid digest..."


Today's Topics:

   1. Re: Random Access on Assets (Jonathan Pryor)
   2. Re: threads in c# vs java example, translated from mark
      murphy android tutorials (Jonathan Pryor)
   3. Re: AtomicBoolean in monodroid? (Jonathan Pryor)
   4. Re: [Monodroid] switching views (again) (Jonathan Pryor)
   5. Re: threads in c# vs java example, translated from mark
      murphy android tutorials (Michael Isbell)
   6. Re: AtomicBoolean in monodroid? (Michael Isbell)
   7. Re: threads in c# vs java example, translated from mark
      murphy android tutorials (Michael Isbell)


----------------------------------------------------------------------

Message: 1
Date: Sat, 19 Mar 2011 09:52:36 -0400
From: Jonathan Pryor <jpryor at novell.com>
Subject: Re: [mono-android] Random Access on Assets
To: "monodroid at lists.ximian.com" <monodroid at lists.ximian.com>
Message-ID: <E818C912-9E98-4319-BF48-D8337110937E at novell.com>
Content-Type: text/plain; charset="us-ascii"

On Mar 19, 2011, at 8:52 AM, "Konaju Games (Dev)" <dev at konaju.com> wrote:
> Android 2.3 lifted the restriction on streaming assets from an .apk and the size of assets in the .apk.
> http://developer.android.com/sdk/android-2.3-highlights.html
> 
> Now all we need is Google to provide the Android 2.3 XML that is used to produce the MonoDroid SDK

Google has, and Preview 14 included API level 10 support (Android v2.3.3). It's 3.0 that we currently missing.

 - Jon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110319/aa6f4b11/attachment-0001.html 

------------------------------

Message: 2
Date: Sat, 19 Mar 2011 11:22:48 -0400
From: Jonathan Pryor <jpryor at novell.com>
Subject: Re: [mono-android] threads in c# vs java example, translated
	from mark murphy android tutorials
To: monodroid at lists.ximian.com
Message-ID: <D000CA21-8C49-4C9E-B0A1-B7049CE8DA66 at novell.com>
Content-Type: text/plain; charset=us-ascii

On Mar 18, 2011, at 11:59 PM, Michael Isbell wrote:
> I'm reworking example number 8 (Threads) from Mark Murphy's Android Java tutorials. Got it working the first time.

I suppose a question that comes up is...why use Java.Lang.Thread instead of System.Threading.Thread? [0]

I understand that when porting code, using the same types is often easiest (hence Java.Lang.Thread), but for the code you provided I don't see any actual need to use it...

 - Jon

[0] For that matter, why use a Thread instead of the TPL of the ThreadPool? :-)

OK, ThreadPool.QueueUserWorkItem() is usually intended for "short" tasks, and your thread isn't, but it's always something to keep in mind...



------------------------------

Message: 3
Date: Sat, 19 Mar 2011 11:26:05 -0400
From: Jonathan Pryor <jpryor at novell.com>
Subject: Re: [mono-android] AtomicBoolean in monodroid?
To: monodroid at lists.ximian.com
Message-ID: <120643CC-AA15-4E4A-B1F7-92EE24842347 at novell.com>
Content-Type: text/plain; charset=us-ascii

On Mar 19, 2011, at 12:33 AM, Michael Isbell wrote:
> Can I create an AtomicBoolean in monodroid?

No, as we're currently not binding the java.util.concurrent.atomic package, as we didn't see any actual need for it (i.e. there are no android.* types or members that use java.util.concurrent types) and .NET already has types which provide this functionality.

Any particular reason you can't use the System.Threading.Interlocked class or other System.Threading types?

 - Jon



------------------------------

Message: 4
Date: Sat, 19 Mar 2011 12:08:08 -0400
From: Jonathan Pryor <jpryor at novell.com>
Subject: Re: [mono-android] [Monodroid] switching views (again)
To: john at murray.gb.com, monodroid at lists.ximian.com
Message-ID: <17C57D7A-0E26-49F0-8C7E-8B1827CA0617 at novell.com>
Content-Type: text/plain; charset=windows-1252

On Mar 19, 2011, at 9:19 AM, John Murray wrote:
> But I just don?t understand why one cannot do this
>  
> [Activity(Label = "monodlgtest1", MainLauncher = true)]
>     public class Activity1 : Activity
>     {
>         int count = 1;
>         protected override void OnCreate(Bundle bundle)
>         {
>             base.OnCreate(bundle);
>             Button button = FindViewById<Button>(Resource.Id.MyButton);
>             button.Click += delegate { bclick();}
>             Button buttonback = FindViewById<Button>(Resource.Id.goBack);
>             buttonback.Click += delegate { bclick2(); };
>             SetContentView(Resource.Layout.Main);
>         }

Problem #1, which is causing you the most grief at the moment: there is no View until you call SetContentView(). Consequently, you _cannot_ call FindViewById<T>() until _after_ SetContentView() is called. Thus, what you _really_ want is this:

>             base.OnCreate(bundle);
>             SetContentView(Resource.Layout.Main);
>             Button button = FindViewById<Button>(Resource.Id.MyButton);
>             button.Click += delegate { bclick();}
>             Button buttonback = FindViewById<Button>(Resource.Id.goBack);
>             buttonback.Click += delegate { bclick2(); };


That said, you didn't provide the source to bclick() and bclick2(). I assume that each of them uses SetContentView() to set the view. This _should_ work, but remember: when you call SetContentView(), you're loading a _new_ object graph, and thus the buttons are no longer configured for the newly loaded view. Consequently, you need to set them back up again:

	void ConfigureButtons()
	{
		FindViewById<Button>(Resource.Id.MyButton).Click += delegate { bclick(); };
		FindViewById<Button>(Resource.Id.goBack).Click += delegate {bclick2(); };
	}

	protected override void OnCreate (Bundle b)
	{
		base.OnCreate(b);
		SetContentView(Resource.Layout.Main);
		ConfigureButtons();
	}

	void bclick()
	{
		SetContentView (Resource.Layout.ButtonOneClicked);
		ConfigureButtons();
		// ...
	}

	void bclick2()
	{
		SetContentView (Resource.Layout.ButtonTwoClicked);
		ConfigureButtons();
		// ...
	}

Note: I have not tested the above, it just seems plausible.

I would still suggest using Activities over what I outlined above.

> I have read through the fundamentals but being a beginner here it doesn?t always make sense to me
> Can someone explain
> a)      Why the above code doesn?t work

SetContentView() was called too late, as described above.

> b)      How one creates matching activities to each view (I presume that would solve the problem)

I would start with the mindset that an "activity" ISA "view," instead of playing the "let's call SetContentView() multiple times!" game (shown above). Instead, you'd use StartActivity() to navigate to a new view, and when the user clicks the Back button they'll naturally return to the previously running Activity (it's a stack), or call Activity.Finish() (which removes the current Activity from the stack). Thus, there is no need for buttons to take you to the next & previous screens, just the need for a button to take you to the next.

For an example, there's the GoogleMaps sample:

	https://github.com/mono/monodroid-samples/tree/master/GoogleMaps

In which StartActivity() is used to launch a (Java-based in GoogleMaps) activity, but the basic idea is the same: clicking a button launches a new activity, which shows a new screen to the user. When the user clicks the Back button, they'll return to the initial screen:

	https://github.com/mono/monodroid-samples/blob/master/GoogleMaps/Activity1.cs#L26

Another example is the VoiceRecognition API Demo, which launches a new activity to invoke the voice recognizer:

	https://github.com/mono/monodroid-samples/blob/master/ApiDemo/App/VoiceRecognition.cs#L79

> c)       Is there a better way of creating a modal data entry dialog

Once you embrace the mult-activity view, the real concern becomes sharing the model (data) between the various activities. This can be done by stuffing the model into a global (static) variable "somewhere", or using the Application object (similarly global), using Intent.Extras (in theory; I haven't tested to see if there are any limitations here), etc.

 - Jon



------------------------------

Message: 5
Date: Sat, 19 Mar 2011 13:04:50 -0400
From: Michael Isbell <michael.isbell at gmail.com>
Subject: Re: [mono-android] threads in c# vs java example, translated
	from mark murphy android tutorials
To: monodroid at lists.ximian.com
Message-ID:
	<AANLkTimJZNyubrJO19dMYGoBYr+2u0ZoJveb=f--NbmE at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

good point about thread pool. I'll change that.

I tried System.Threading.Thread and the interface wasn't quite right. Now
that I have this working, I'll take another look.



On Sat, Mar 19, 2011 at 11:22 AM, Jonathan Pryor <jpryor at novell.com> wrote:

> On Mar 18, 2011, at 11:59 PM, Michael Isbell wrote:
> > I'm reworking example number 8 (Threads) from Mark Murphy's Android Java
> tutorials. Got it working the first time.
>
> I suppose a question that comes up is...why use Java.Lang.Thread instead of
> System.Threading.Thread? [0]
>
> I understand that when porting code, using the same types is often easiest
> (hence Java.Lang.Thread), but for the code you provided I don't see any
> actual need to use it...
>
>  - Jon
>
> [0] For that matter, why use a Thread instead of the TPL of the ThreadPool?
> :-)
>
> OK, ThreadPool.QueueUserWorkItem() is usually intended for "short" tasks,
> and your thread isn't, but it's always something to keep in mind...
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



-- 
Mike Isbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110319/6e13df59/attachment-0001.html 

------------------------------

Message: 6
Date: Sat, 19 Mar 2011 13:06:03 -0400
From: Michael Isbell <michael.isbell at gmail.com>
Subject: Re: [mono-android] AtomicBoolean in monodroid?
To: monodroid at lists.ximian.com
Message-ID:
	<AANLkTimjT3fzHRJtp4C5nWDT06wW6UPVhi4CnBehTbti at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Nope, just seeing how close I can stick to original code. I'll synchronize
it as you've suggested.

On Sat, Mar 19, 2011 at 11:26 AM, Jonathan Pryor <jpryor at novell.com> wrote:

> On Mar 19, 2011, at 12:33 AM, Michael Isbell wrote:
> > Can I create an AtomicBoolean in monodroid?
>
> No, as we're currently not binding the java.util.concurrent.atomic package,
> as we didn't see any actual need for it (i.e. there are no android.* types
> or members that use java.util.concurrent types) and .NET already has types
> which provide this functionality.
>
> Any particular reason you can't use the System.Threading.Interlocked class
> or other System.Threading types?
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



-- 
Mike Isbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110319/968a472f/attachment-0001.html 

------------------------------

Message: 7
Date: Sat, 19 Mar 2011 13:44:20 -0400
From: Michael Isbell <michael.isbell at gmail.com>
Subject: Re: [mono-android] threads in c# vs java example, translated
	from mark murphy android tutorials
To: monodroid at lists.ximian.com
Message-ID:
	<AANLkTi=7v3_eGPZfaZaP-kfi=uG2sNq2CdjYkDbJr2Wq at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

And a more honest answer to the question is that, while I programmed
exclusively in C# between 2001 and 2008, I haven't even looked at it since I
got buried in objc...so some of this is that I don't remember what I use to
know :-) just bought accelerated C# and jeff richter to remind me how all
this works.

yes, on my Kindle of course. Don't you judge me!





On Sat, Mar 19, 2011 at 1:04 PM, Michael Isbell <michael.isbell at gmail.com>wrote:

> good point about thread pool. I'll change that.
>
> I tried System.Threading.Thread and the interface wasn't quite right. Now
> that I have this working, I'll take another look.
>
>
>
> On Sat, Mar 19, 2011 at 11:22 AM, Jonathan Pryor <jpryor at novell.com>wrote:
>
>> On Mar 18, 2011, at 11:59 PM, Michael Isbell wrote:
>> > I'm reworking example number 8 (Threads) from Mark Murphy's Android Java
>> tutorials. Got it working the first time.
>>
>> I suppose a question that comes up is...why use Java.Lang.Thread instead
>> of System.Threading.Thread? [0]
>>
>> I understand that when porting code, using the same types is often easiest
>> (hence Java.Lang.Thread), but for the code you provided I don't see any
>> actual need to use it...
>>
>>  - Jon
>>
>> [0] For that matter, why use a Thread instead of the TPL of the
>> ThreadPool? :-)
>>
>> OK, ThreadPool.QueueUserWorkItem() is usually intended for "short" tasks,
>> and your thread isn't, but it's always something to keep in mind...
>>
>> _______________________________________________
>> Monodroid mailing list
>> Monodroid at lists.ximian.com
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>>
>
>
>
> --
> Mike Isbell
>
>
>


-- 
Mike Isbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110319/1c7f564a/attachment.html 

------------------------------

_______________________________________________
Monodroid mailing list
Monodroid at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodroid


End of Monodroid Digest, Vol 8, Issue 84
****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110323/dd837df3/attachment.html 

------------------------------

_______________________________________________
Monodroid mailing list
Monodroid at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodroid


End of Monodroid Digest, Vol 8, Issue 103
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110323/b419703c/attachment-0001.html 


More information about the Monodroid mailing list