1

我从带有复选框的适配器生成一个工作列表视图:

final ArrayList<String> ArrayListHouse = new ArrayList<String>();
do
{
String ColumnNameTemp = myDBcursor.getString(ColumnIndexName);
ArrayListHouse.add(ColumnNameTemp);
}while (myDBcursor.moveToNext());

ListView = new ListView(getActivity());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_checked, ArrayListHouse);
listView.setAdapter(adapter);

现在我想在应用程序停止后重新生成复选框的状态。使用 sharedprefs 或我的数据库保存选中的复选框对我来说没有问题。但是我在尝试使用预定义的复选框加载列表时遇到了很多麻烦。什么是正确的机制?有什么例子吗?

再见卡斯滕

4

1 回答 1

0

http://developer.android.com/reference/android/widget/AbsListView.html#setItemChecked(int, boolean) Here is what you need:

AbsListView.setItemChecked(int, boolean)

by the way, how many checkboxes do you have? probably it would be better to put them in LinearLayout and ScrollView manually ?

于 2012-11-22T14:53:44.230 回答