Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.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 Listview问题:无法使用<;ListView></ListView>;在布局xml中?_Android_Xml_Listview_Layout - Fatal编程技术网

Android Listview问题:无法使用<;ListView></ListView>;在布局xml中?

Android Listview问题:无法使用<;ListView></ListView>;在布局xml中?,android,xml,listview,layout,Android,Xml,Listview,Layout,我试着写一个xml,就像下面的xml一样,但总是会有一个例外 这“是由以下原因引起的:java.lang.UnsupportedOperationException: Adapterview中不支持addView(View,LayoutParams)。 据说在布局中xml不能使用,并且 它应该是,并使用java代码进行操作,是吗 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http:/

我试着写一个xml,就像下面的xml一样,但总是会有一个例外 这“是由以下原因引起的:java.lang.UnsupportedOperationException: Adapterview中不支持addView(View,LayoutParams)。 据说在布局中xml不能使用
,并且 它应该是
,并使用java代码进行操作,是吗

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="8dp"
        android:paddingRight="8dp">

    <ListView android:id="@+id/listview"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="#00FF00"
              android:layout_weight="1"
              android:drawSelectorOnTop="false">

    <TextView
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="#000000"
              android:text="No data"/>
  </ListView>
</LinearLayout>


您不能以这种方式将
文本视图
放入
列表视图
中。您需要将
ListAdapter
对象与
ListView
关联。最后,我找到了我需要的scrollview。谢谢您的回复。 例如:


…还是别的什么

你能详细说明你的答案吗??我也有同样的问题,而且很难把它解决。@BennettVonBennett:这是我的一本书的免费摘录,内容更详细:
  <ScrollView>
   <LinearLayout>
   <TextView/>
   <TextView/>
   ...or something else
   <TextView/>
   </LinearLayout>
  </ScrollView>