MapView加载监听器
有没有办法将 loadListener 附加到 MapView 小部件?
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="my api key" />
</LinearLayout>
Java:
mapView = (MapView) findViewById(R.id.mapview);
mapView. // attach listeners?
Is there a way to attach a loadListener to the MapView widget?
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
>
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="my api key" />
</LinearLayout>
Java:
mapView = (MapView) findViewById(R.id.mapview);
mapView. // attach listeners?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编写一个方法,为您要在创建后附加的 MapView 创建侦听器,然后让它获取要附加侦听器的 MapView。
像
然后 只需使用需要附加所有侦听器的 MapView 来调用它即可。
编辑
现在我完全明白你想要做什么了。
因此,您需要监听
onFinishInflate()
事件。如果您想了解更多详情,请点击这里
Android 开发视图
You could just write a method that creates the listeners for the
MapView
that you want to attach after you create it, and just have it take the mapview to attach the listener to.Something like
Then just call that with the MapView that needs all of the listeners attached.
Edit
Now I get exactly what you are trying to do.
So you will want to listen for the
onFinishInflate()
Event.More here if you want specifics
Android Dev View