我正在尝试使用 ListView 在其他小部件中实现活动。因此,如果我理解正确,我将无法使用 ListActivity(因为它只显示一个对我来说可以的大 ListView)。
我从 SO like this
or
this
or great example中发现了很多在 java 中执行此操作的不同示例。
我试过以同样的方式做,但它不能正常工作。我很好奇这个功能是否存在于单声道android中?
我发现只有一个在单声道 android 中使用 ListView 的例子 , 这个例子描述了只使用 ListActivity。
所以,我的布局:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
android:id="@+id/widget36"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
</TableLayout>
我的创建:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.CreateUser);
JavaList<string> somadata = new JavaList<string> { "111", "222", "333" };
ListView view = FindViewById<ListView>(Resource.Id.list);
view.Adapter = new ArrayAdapter<string>(this, Resource.Layout.CreateUser, somadata);
view.TextFilterEnabled = true;
}