" or "/>"的解決辦法" type="hidden"/>

Element type "LinearLayout" must be followed by either attribute specifications, ">" or "/>"的解決辦法


  看老師的word文檔開始學習。復制了一段代碼,在layout中新建了一個Android XML file,發現有提示錯誤。

  代碼如下:

<?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" >
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hello, I am a TextView" />
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello, I am a Button" />
</LinearLayout>

   錯誤的提示是這樣的:Element type "LinearLayout" must be followed by either attribute specifications, ">" or "/>".

  在網上找了很久,都沒有找到我理想的解決方案。這樣幾個小時就過去了。

  后來自己無意間試了出來一種辦法,居然可以消除這種錯誤。那就是右鍵點擊這個xml文件,然后new -> Android XML flie -> finish。也就是新建一個相同名字的xml文件來覆蓋這個文件。感覺內容是沒有修改的,但是就是正確了。我的猜測是:word和eclipse的編碼可能不同。但是具體是什么原因就不知道了。

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM