2013-04-08 66 views
3

我有一段时间让AdMob工作。错误发生后我有错误,并且不止一次地报废了整个事件。现在,我收到来自XML的错误,说它不会解析正确的。代码如下。我看过其他答案,但我似乎无法弄清楚什么是错的。如果有人可以看看我的布局文件,并让我知道我在做什么错我会大大欣赏它。我直接从AdMob网站使用适合我自己的应用程序的代码,这是值得的。Adview错误解析XML无约束前缀Android

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

android:id="@+id/AdLinearLayout" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:orientation="vertical" > 

<!-- Ad Placeholder --> 

<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="a15138b1a7adad2" 
    ads:loadAdOnCreate="true" 
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" /> 

<ScrollView 
    android:id="@+id/BaseScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/baseVerticalLinearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

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

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/Sad" /> 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Happy" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/happinessBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

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

      <TextView 
       android:id="@+id/textView3" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/Tired" /> 

      <TextView 
       android:id="@+id/textView4" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Awake" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/energyBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

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

      <TextView 
       android:id="@+id/textView5" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/Calm" /> 

      <TextView 
       android:id="@+id/textView6" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Anxious" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/anxietyBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

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

      <TextView 
       android:id="@+id/textView7" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="left" 
       android:text="@string/No_Pain" /> 

      <TextView 
       android:id="@+id/textView8" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="right" 
       android:text="@string/Max_Pain" /> 
     </LinearLayout> 

     <SeekBar 
      android:id="@+id/painBarID" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:max="@integer/SliderMax" 
      android:progress="@integer/SliderDefault" /> 

     <DatePicker 
      android:id="@+id/datePicker1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <TimePicker 
      android:id="@+id/timePicker1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <EditText 
      android:id="@+id/noteTextFieldID" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:hint="@string/Note_Hint" 
      android:inputType="textMultiLine" 
      android:maxLength="@integer/NoteLimit" /> 

     <Button 
      android:id="@+id/enterButtonID" 
      android:layout_width="132dp" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:onClick="dialogPop" 
      android:text="@string/EnterButtonText" /> 
    </LinearLayout> 
</ScrollView> 

回答

17

变化:

android:ads="http://schemas.android.com/apk/lib/com.google.ads" 

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

AdMob要求您使用自己的包中定义的属性。为了不必每次都输入该URL,我们使用xmlns声明XML名称空间,就像我们为android所做的一样。您使用android而不是xmlns作为前缀声明的前缀,这会导致您的错误。

+0

是所有它是什么?为什么它必须是那个?我问为什么,因为它会帮助我知道未来。 – fauxfire76 2013-04-08 18:15:38

+0

拉格哈夫,包括背后的原因,以便他/她会知道,我相信他/她不会再犯这样的错误。 – 2013-04-08 18:15:40

+0

@ fauxfire76看我的编辑。 – 2013-04-08 18:18:29

0

加入这一行布局

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"