Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android “元素类型”;“列表视图”;必须后跟属性规范中的任何一个&燃气轮机&引用;或/&燃气轮机&引用;_Android_Xml_Eclipse_Listview_Android Listview - Fatal编程技术网

Android “元素类型”;“列表视图”;必须后跟属性规范中的任何一个&燃气轮机&引用;或/&燃气轮机&引用;

Android “元素类型”;“列表视图”;必须后跟属性规范中的任何一个&燃气轮机&引用;或/&燃气轮机&引用;,android,xml,eclipse,listview,android-listview,Android,Xml,Eclipse,Listview,Android Listview,我正在用JavaXML为android制作一个列表视图。但是一个让我非常恼火的错误…我已经搜索了以前的错误解决方案,但是它们对我不起作用…所以请帮助我 当我从图形布局中选择ListView和按钮时,代码是 <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="tru

我正在用JavaXML为android制作一个列表视图。但是一个让我非常恼火的错误…我已经搜索了以前的错误解决方案,但是它们对我不起作用…所以请帮助我

当我从图形布局中选择ListView和按钮时,代码是

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button" />

<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >

</ListView>

此代码工作正常。。但是当我在Listview中以这种方式编辑行代码时

<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
*android:layout_above="@+id/button1"
>

</ListView>

在*所示的行中,我发现了错误,并说:

元素类型“ListView”后面必须跟属性规范“>”或“/>”

我认为语法是正确的。。。不仅在ListView id中,我尝试编辑按钮,然后同样的错误出现在相同的位置。说:

“元素类型”按钮“后面必须跟属性规范“>”或“/>”

我查看了之前的帖子,但他们说标签没有关闭,对我不起作用。请建议并帮助我…怎么办

完整代码为:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.bimal.blutooth.MainActivity$PlaceholderFragment" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button" />

<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_above="@+id/button1"
>

</ListView>
</RelativeLayout>

我会尝试重新启动eclipse。你的代码没有在我的机器上显示任何错误。有时eclipse检查代码的方式存在缺陷。有时它只需要重新启动

如果你是一个解决方案的游戏,这是一个类似的布局,有更多的代码,但它避免了相对布局

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:weightSum="1"
tools:context="com.bimal.blutooth.MainActivity$PlaceholderFragment" >

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".1">
        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="352dp" >

        </ListView>
    </LinearLayout>

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".9">
        <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </LinearLayout>

</LinearLayout>

您可以在“之后添加空格

例如:

可能是……我会试试@user3331142它对我不起作用。。再次,当我在中添加一行代码时,这是一件非常奇怪的事情。正如我所说,它在eclipse中对我起作用,当我在手机上运行代码时,它工作得非常好。我仍然相信这是一个eclipse错误,但如果不是,我绝对没有任何线索。我在回答中添加了一个变通方法。它避免了ds的相对布局,但它需要更多的代码“有时Eclipse只需要重新启动。”-这让我咯咯地笑了起来…但是这个错误经常困扰着我…尝试了所有的可能性…但仍然没有得到正确的解决方案…神秘的…:)在这里添加一些描述。逻辑比一段代码更有用。
eg:<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight=".1">
    <ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="352dp" ></ListView>