[mono-android] persistent putextra etc

Morten Nilsen mortenn at hapro.no
Wed Mar 23 08:02:15 EDT 2011


Something like the following ought to just work;

Public static class SomeClass
{
                Public static Something SomeValue;
}

Public class SomeOtherClass
{
                Public void DoSomething()
                {
                               SomeClass.SomeValue = new Something();
                }
}

Public class SomeThirdClass
{
                Public void ShowSomething()
                {
                               Something value = SomeClass.SomeValue;
                               …
                }
}

  -- Cheers, Morten


From: monodroid-bounces at lists.ximian.com [mailto:monodroid-bounces at lists.ximian.com] On Behalf Of John Murray
Sent: Wednesday, March 23, 2011 12:55 PM
To: monodroid at lists.ximian.com; john at murray.gb.com
Subject: Re: [mono-android] persistent putextra etc

Thanks Tiago
Yes but....
If I declare my class as static – I can’t create an instance of it so how do I use it?  C# does not allow one to create instances of a static class

If I create an instance of the class and declare it static thus – in activity1
public static vineGar vGar = new vineGar();
it is not visible in activity2

I cannot create an instance of the class outside an activity so I’m stumped how one uses statics

Where and how does ne declare a class or a variable (array) as static so it is visible across all activities
An example would be helpful

TIA
John Murray


From: monodroid-bounces at lists.ximian.com [mailto:monodroid-bounces at lists.ximian.com] On Behalf Of Tiago Reis
Sent: 23 March 2011 10:41
To: john at murray.gb.com; monodroid at lists.ximian.com
Cc: john Murray
Subject: Re: [mono-android] persistent putextra etc

3)      Is there an easier way? – cant figure how to make a static visible in all activities –

This should work, if your static is public :s I'm using this in my app :s
On Wed, Mar 23, 2011 at 10:10 AM, john Murray <john at murray.uk.com<mailto:john at murray.uk.com>> wrote:
Sorry to ask for help once again on this
I have mastered activities and putting and getting extras  but only with simple data forms such as strings
I’ve struggled a bit with arrays but as long as they are simple (arraylists seemed t be a ‘no no’ when creating a bundle to pass t put extra)

What I really want to do is pass an instance of a data class – just a rather big form with a few one-to-many fields of data
e.g.  vehicle details-journey details  – several pax

so I have a class called vehicle which contains and collects the data from forms which are actually different activities
I want the instance of this class to be available in all activities

I cannot figure out how to pass the instance of the class using bundle and putextras
It seems to be something to do with parcelable data – ie. My   vehicle class needs to be parcelable
I’ve found something on this but it might as well be Fermatts last theorem


1)      Am I right about the parcelable stuff

2)      How do I make my class parcelable

3)      Is there an easier way? – cant figure how to make a static visible in all activities –

4)      My fall back position is to pass a load of simple arrays or to serialize to storage between activities







Thanks in advance

John Murray



_______________________________________________
Monodroid mailing list
Monodroid at lists.ximian.com<mailto:Monodroid at lists.ximian.com>

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



--
Tiago Reis

www.cardmobili.com<http://www.cardmobili.com>
tiago.reis at cardmobili.com<mailto:tiago.reis at cardmobili.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110323/890483e6/attachment-0001.html 


More information about the Monodroid mailing list