2013-04-08 40 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" 
相關問題