android中的2个类之间进行通信
好的,我有 2 个类
一个活动类和另一个从 maps.Overlay
扩展的类。因此,二等舱不能从一等舱延长,因为它已经延长了。
我的第二个课程从地图上的用户触摸位置获取地理坐标。我想要做的是显示一个窗口(不是警报框)以继续。为了做到这一点,我必须以某种方式提醒活动班。因为我无法调用 setContentView(R.layout.insertwin)
;在我的第二堂课上。不知何故,它必须需要调用活动类。我该怎么做呢?
ok I have 2 classes
an activity class and another class which extended from maps.Overlay
. so the second class cannot be extended from first class because it already extended.
my second class gets the geo coordinates from user touch location on a map. what I want to do is show a window(not alert box) to proceed. In order to do that, I have to alert the activity class somehow. because I can't call setContentView(R.layout.insertwin)
; in my second class. somehow it must need to call in the activity class. how would I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在
View
子类中创建自己的监听器接口,并在调用setContentView()
后在Activity
子类中订阅此监听器。因此,您将能够通知您的活动有关您想要的任何事件。You can do your own listener interface in the
View
subclass and subscribe to this listener int theActivity
subclass after callingsetContentView()
. So you'll be able to notify your activity about any events you want.你可以实现单例来做这样的事情
You can implement singleton to do such things