Re: passing around class instances?

  • From: "black ares" <matematicianu2003@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 10 May 2010 07:49:40 +0300

you can make an collection of objects in the C class, assign to every object an id, let say the position in the array/coollection

and pass to the child the ID.
Then the child will access the C class and will ask for the specific instance from the collection.

----- Original Message ----- From: "mehgcap" <mehgcap@xxxxxxxxx>
To: "programmingblind" <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, May 09, 2010 9:50 PM
Subject: java: passing around class instances?


Hi all,
I am working with Android (yet again). Because of the way Android
works, you cannot have a dialog created that takes arguments from the
parent; instead, you use a data structure called an intent, in which
you put everything the child needs to run. However, I have a
non-serializable object (intents only accept primitives, strings, and
serialized objects) which the child needs to access but which is
created in the parent. I want to know how I can give two separate
classes, one of which is the main class, access to the same instance
of an object? As a simple example, say we have object o, in class c.
Class a is the parent and has in it the line:
c obje=new c();

Now, class a's child, class b, needs access not just to class c, but
to the specific obj instance of c that was made in a. Is there a way
to let both classes share the same instance of an object without
serializing? I maybe could import a inside b, but a is the main file
(runs at application start) so I feel like that would not be a great
way of doing things. Any ideas or thoughts would be greatly
appreciated. I can post the android code if you want, but I am not
sure how much good it would do.

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts:

  • » Re: passing around class instances? - black ares