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

  看老师的word文档开始学习。复制了一段代码,在layout中新建了一个Android XML file,发现有提示错误。android

  代码以下:eclipse

<?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的编码可能不一样。可是具体是什么缘由就不知道了。spa

相关文章
相关标签/搜索