Добавление вида карты во вкладки в Android - PullRequest
1 голос
/ 19 января 2012

Я искал учебники и тому подобное в интернете, но я не нашел ни одного решения, которое бы сработало, поэтому я почему бы не спросить его здесь ??? Мне удалось использовать просмотры карт вне вкладок, но как я могу показать 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>

1 Ответ

3 голосов
/ 19 января 2012

У меня есть проект с MapView в Tab.

enter image description here

Вот источник и расположение вкладок: Вкладка Source | Вкладка XML

А вот источник и макет для MapView, который загружается во вкладку: Источник карты | Карта XML

Я надеюсь, что вы можете адаптировать этот код для своего собственного проекта, удачи!

...