2014-12-13 52 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