【问题标题】:Adding mapview into tabs in android将mapview添加到android中的选项卡中
【发布时间】:2023-03-31 10:59:01
【问题描述】:

我已经在互联网上搜索了教程等,但我还没有提出任何可行的解决方案,所以我虽然,为什么不在这里问呢?我已经设法在选项卡外使用地图视图,但是如何在地图选项卡内显示 xml?请提前解释并感谢! 我需要在“地图”选项卡上添加一个 MapView,我该怎么做???这是我用于标签的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>

<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabHost"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs"
/>
 <FrameLayout
 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabcontent"
 >
 <LinearLayout
 android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tab1"
android:orientation="vertical"
android:paddingTop="60px"
 >
 <TextView  
android:layout_width="fill_parent" 
android:layout_height="100px" 
android:text="My tracks"
android:id="@+id/txt1"
/>

 </LinearLayout>

 <LinearLayout

 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tab2"
android:orientation="vertical"
android:paddingTop="60px"
 >
 <TextView  
android:layout_width="fill_parent" 
android:layout_height="100px" 
android:text="Map"
android:id="@+id/txt2"
/>

 </LinearLayout>

  <LinearLayout
 android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tab3"
android:orientation="vertical"
android:paddingTop="60px"
 >

 <TextView
     android:id="@+id/txt3"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="Search for gokart tracks" />


 <LinearLayout
     android:id="@+id/linearLayout1"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >

     <EditText
         android:id="@+id/SearchInput"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="10.05" >

         <requestFocus />
     </EditText>

     <Button
         android:id="@+id/SearchButton"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:text="@android:string/search_go" />

 </LinearLayout>

 </LinearLayout>

 </FrameLayout>

</TabHost>

【问题讨论】:

标签: android xml map tabs android-mapview


【解决方案1】:

我的项目在Tab 中有一个MapView

以下是 Tabs 的来源和布局: Tab Source | Tab XML

这是在 Tab 中加载的 MapView 的源代码和布局: Map Source | Map XML

希望你能把这段代码改编成你自己的项目,祝你好运!

【讨论】:

  • 试过了,但问题是:它只显示另一个窗口,它没有在地图选项卡内显示地图。那就是问题所在。顺便说一句,非常感谢
  • 代码运行正常,我添加了运行时的样子。
  • 代码太远了,无法通过漏洞代码,但是你能把在选项卡中显示 xml 布局文件的代码发给我吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多