【发布时间】:2010-11-03 05:42:24
【问题描述】:
我尝试编写如下 xml 的 xml,但总是得到一个异常说
那“引起:java.lang.UnsupportedOperationException:
Adapterview 不支持 addView(View,LayoutParams)”。
据说在布局xml中不能使用<ListView> </ListView>,并且
它应该是<ListView />并使用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>
【问题讨论】:
标签: android xml listview layout