我想要一个布局,以便用户可以在 ListView 和 map View 之间切换以及单击菜单按钮。首次创建 Activity 时,它会从服务器获取数据并显示列表结果,然后单击菜单按钮将所有结果映射到 mapview 上。 我遇到的问题是在用户单击刷新结果菜单按钮后最初和再次显示加载屏幕。 我的布局如下, Activity 扩展了 MapActivity。当调用 notifyDataSetInvalidated() 时列表数据可用时,我希望加载 View 消失。我在没有 mapview 的其他 Activity 中使用了类似的逻辑,并且 Activity 扩展了列表 Activity 并且它有效但在这种情况下无效。
<?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:id="@+id/data_view"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
>
<ListView
android:id="@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:drawSelectorOnTop="false"
android:scrollbars="vertical"
/>
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:clickable="true"
android:visibility="gone"
android:apiKey="@string/google_maps_api_key"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@color/white"
>
<ProgressBar
android:id="@+id/emptyProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dip"
style="?android:attr/progressBarStyleSmall"
/>
<TextView
android:id="@+id/emptyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/loading"
/>
</LinearLayout>
</LinearLayout>
最佳答案
我决定使用 FrameLayout 并根据要显示的内容在这 3 个 View 之间切换。
关于android listview mapview布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4652127/