开发者

Is there a Java equivalent to Actionscript's 3.0 Event dispatching? Or, how do I effectively communicate between unrelated class instances?

开发者 https://www.devze.com 2023-03-23 09:06 出处:网络
I\'m starting out in Android development and this has been bugging me a little. If class A creates an instance of class B and class C, what is the easiest way to communicate between B and C?

I'm starting out in Android development and this has been bugging me a little.

If class A creates an instance of class B and class C, what is the easiest way to communicate between B and C?

In Actionscript 3, I could dispatch an event and have a listener pi开发者_JS百科ck it up and act on it but I cannot see something like that in Java. Of course there is the option of passing a reference of B and C into the other from class A but when the path isn't this simple it becomes very hard to follow.

What is the best way to accomplish this in Java/Android?


For Android, I think the best way is to use the Intent api: http://developer.android.com/guide/topics/intents/intents-filters.html

Regards, Deluan.

0

精彩评论

暂无评论...
验证码 换一张
取 消