Android: Google MapView в ViewFlipper - PullRequest
       8

Android: Google MapView в ViewFlipper

0 голосов
/ 06 сентября 2011

У меня есть макет, который использует ViewFlipper для постоянного отображения панели вкладок во всем приложении.

Основная деятельность расширяет TabActivity.Для одного из моих представлений, я хочу иметь представление карты, я пробовал этот код безуспешно:

<ViewFlipper android:id="@+id/layout_tab_one"
                android:layout_width="fill_parent" android:layout_height="fill_parent">

                <ListView android:id="@+id/listview" 
                    android:layout_width="fill_parent" android:layout_height="wrap_content" />

                <com.google.android.maps.MapView
                 android:id="@+id/mapview"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:clickable="true"
                 android:apiKey="myapikey">
                  </com.google.android.maps.MapView>  
                <ListView android:id="@+id/lazylistview"
                    android:layout_width="fill_parent" android:layout_height="wrap_content" />
                    <include android:id="@+id/cell1" layout="@layout/detail" />
                <ListView android:id="@+id/listview2" 
                    android:layout_width="fill_parent" android:layout_height="wrap_content" />

            </ViewFlipper>

Приложение вылетает при запуске.Я поместил пользовательскую библиотеку для карт Google в манифест, и я также запускаю приложение, используя Google API, но все же не повезло.Какие-либо предложения?Спасибо!

Ответы [ 2 ]

0 голосов
/ 14 сентября 2014

Используйте расширение FragmentActivity для действия, в котором инициализируется ViewFlipper

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/RelativeLayout02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ViewFlipper
            android:id="@+id/flipper"
            android:layout_width="fill_parent"
            android:layout_height="400dp" >

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <fragment
                    android:id="@+id/map"
                    android:name="com.google.android.gms.maps.SupportMapFragment"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </RelativeLayout>           
        </ViewFlipper>
    </RelativeLayout>
</LinearLayout>

, и используйте код ниже

int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());  

        if (checkGooglePlayServices != ConnectionResult.SUCCESS) { 
            GooglePlayServicesUtil.getErrorDialog(checkGooglePlayServices, (Activity) context, 1122).show();
            return;
        }
0 голосов
/ 06 сентября 2011

Либо ваше устройство или эмулятор не имеет Google Maps, либо, возможно, вы надуваете этот макет из чего-то другого, чем MapActivity.

...