2014-12-13 90 views
0

我要在我的應用程序中使用Google地圖V2,所以我在網上跟隨教程,如this使用片段的錯誤

但是,當我在XML佈局和運行應用程序中使用片段標籤,就躍升到日食的DEBUG窗口(視圖)。

我檢查了我的代碼一行行,當我使用XML佈局片段標籤出現第一個錯誤!

我創建了一個測試應用程序(如下所示),並再次出現錯誤。

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

<fragment 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

</LinearLayout> 

和我的java類:

public class Main extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    } 
} 

我知道,當我在我的佈局中使用片段標籤,我會遇到錯誤。

你能告訴我什麼是錯的!

+0

PLS添加logcat的錯誤文件 – Rahul 2014-12-13 12:37:15

回答

2

將在清單中的應用程序標籤下面的代碼,他錯過了在這個例子

<meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 

並替換佈局文件

<fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.MapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
+0

坦克你下面那行提示...這是我的問題的解決方案 – 2014-12-13 14:18:52