Android Listview问题:无法使用<;ListView></ListView>;在布局xml中?
我试着写一个xml,就像下面的xml一样,但总是会有一个例外 这“是由以下原因引起的:java.lang.UnsupportedOperationException: Adapterview中不支持addView(View,LayoutParams)。 据说在布局中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:/
,并且
它应该是
,并使用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>