如何在不同的类/选项卡中显示详细地图和高级地图?

发布于 2024-12-25 22:38:39 字数 2347 浏览 0 评论 0原文

我有两个活动,ListViewActivity 和 MapViewActivity,它们都在 TabHost 中运行;一切工作正常,我可以查看我的列表、向地图添加 POI、在选项卡之间进行更改等。

我还所做的是“扩展”我的 ListViewActivity,这样当单击列表中的项目时,视图就会显示切换(通过 ViewSwitcher)以显示更多详细信息(注意:这发生在同一选项卡内);再次,这一切都正常,我可以在列表视图和包含文本元素、按钮等的详细视图之间切换。

但是,由于我只用 Android/JAVA 编程了几周,所以我遇到了一个问题砖墙......并且需要一些指示/高级示例来让我再次前进。

  <com.google.android.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:apiKey="0sQLOXF5j7iM03sd-IyVldoGjh0voa5-qqFRRlw"
    android:clickable="false"
    android:enabled="true" />

具体来说,我希望 ListViewActivity 中的“扩展/详细”视图包含详细/缩放的地图。但是,当我尝试在 XML 代码中包含地图定义时(见上文),它会导致应用程序崩溃 - 我假设是因为 MapViewActivity 中已经定义了一个地图(即此代码同时出现在我的 ListViewActivity.xml 和我的 MapViewActivity.xml 文件)?

我读过发现其他页面,例如 this,建议使用清单中的 android:process 属性来分配活动,例如:

activity android:name=".activity.directory.MapView1" android:process=":MapView1"
activity android:name=".activity.directory.MapView2" android:process=":MapView2"

但是,我不确定如何实现这一点 - 即如何从 ListViewActivity 或MapViewActivity 类可以显示详细地图或高级地图?

目前我的 AndroidManifest.XML 文件如下所示;我知道这是不正确的,但就像我说的,我一直在想办法如何在我的 ListViewActivity 和 MapViewActivity 中都有地图:

  <application
    android:icon="@drawable/launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".DummyAppName" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".ListViewActivity"/>
    <activity android:name=".MapViewActivity"/>
    <activity android:name=".FavouritesActivity"/>
    <activity android:name=".SettingsActivity"/>
    <activity android:name=".activity.directory.MapView1" android:process=":MapView1"/>
    <activity android:name=".activity.directory.MapView2" android:process=":MapView2"/>

抱歉,这篇文章很长。我希望这是有道理的,我希望有人能够就如何解决我的问题提供一些想法/建议(甚至可能吗?)。

谢谢你!

I have two activities, ListViewActivity and MapViewActivity which both run within a TabHost; everything is working fine and I am able to view my list, add POIs to the map, change between tabs etc.

What I have also done is to 'extend' my ListViewActivity so that when an item in the List is clicked, the view is switched (via ViewSwitcher) to show more detail (note: this happens within the same tab); again this all works okay and I am able to flip between the list view and the detailed view which contains text elements, buttons etc.

But, since I've only been programming in Android/JAVA for a few weeks, I've hit a brick wall... and need some pointers/high level examples to get me going again.

  <com.google.android.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:apiKey="0sQLOXF5j7iM03sd-IyVldoGjh0voa5-qqFRRlw"
    android:clickable="false"
    android:enabled="true" />

Specifically, I want the 'extended/detailed' view within the ListViewActivity to include a detailed/zoomed map. However, when I try to include the map definition in my XML code (see above), it causes the application to crash - I am assuming because there is already a map defined in MapViewActivity (i.e. this code appears in both my ListViewActivity.xml and my MapViewActivity.xml files)?

I've read found other pages such as this, which recommend using the android:process attribute in the manifest to assign acitivites, for example:

activity android:name=".activity.directory.MapView1" android:process=":MapView1"
activity android:name=".activity.directory.MapView2" android:process=":MapView2"

However, I am uncertain how to implement this - i.e. how do I call the process from either the ListViewActivity or MapViewActivity class such that either a detailed or high-level map is displayed?

Currrently my AndroidManifest.XML file is as shown below; I know this is incorrect, but like I said, I'm stuck in figuring out how to have a map both in my ListViewActivity and in my MapViewActivity:

  <application
    android:icon="@drawable/launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".DummyAppName" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".ListViewActivity"/>
    <activity android:name=".MapViewActivity"/>
    <activity android:name=".FavouritesActivity"/>
    <activity android:name=".SettingsActivity"/>
    <activity android:name=".activity.directory.MapView1" android:process=":MapView1"/>
    <activity android:name=".activity.directory.MapView2" android:process=":MapView2"/>

Sorry for the long post. I hope it makes sense and I hope someone is able to offer some ideas/suggestions on how to fix my problem (is it even possible?).

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文