android中的2个类之间进行通信

发布于 2024-10-27 17:41:05 字数 294 浏览 4 评论 0原文

好的,我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愛上了 2024-11-03 17:41:05

您可以在View子类中创建自己的监听器接口,并在调用setContentView()后在Activity子类中订阅此监听器。因此,您将能够通知您的活动有关您想要的任何事件。

You can do your own listener interface in the View subclass and subscribe to this listener int the Activity subclass after calling setContentView(). So you'll be able to notify your activity about any events you want.

千と千尋 2024-11-03 17:41:05

你可以实现单例来做这样的事情

You can implement singleton to do such things

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文