ステップ1:カスタム列の代わりTextView
のCheckedTextView
とCheckBox
custom_row.xmlを使用して
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/chkTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
ステップ2:あなたの活動で
public void onItemClick(AdapterView<?> arg0, View view, int postion, long id) {
hold the selected item position in a array list (depends upon the item is checked or unchecked.)
}
ステップ3: 「実行」ボタンをクリックすると、選択された位置がいずれかの記憶方法(最も望ましいオブジェクトキャッシュ)で保持されます。
ステップ4: 活動を作成中:
ステップ4.1:永続IDを取得します:ライン
以下
listvw = (ListView)findViewById(android.R.id.list);
listvw.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
ステップ4.2を追加します。 非常に最初の呼び出しであれば、永続化されたv alueはnullまたはリストサイズ0です。
long[] checkedItemIds = retriveFromPersistence();
if (checkedItemIds != null) {
for(int id_count = 0; id_count < checkedItemIds.length; id_count++) {
listvw.setItemChecked((int) checkedItemIds[id_count], true);
}
}
[http://stackoverflow.com/questions/8320663/android-how-to-redraw-list-when-the-user-sets-、それはあなたを助けるかもしれない、この答えを参照してください。チェックボックス] [1] [1]:http://stackoverflow.com/questions/8320663/android-how-to-redraw-list-when-the-user-sets-checkbox – Hasmukh