teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

誤字

2017/06/02 08:39

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -28,7 +28,7 @@
28
28
  })
29
29
  }
30
30
  ```
31
- adapter
31
+ adapter
32
32
 
33
33
  ```kotlin
34
34
  class ImageCursorAdapter(val context: Context?, c: Cursor?, flags: Int) : CursorAdapter(context, c, flags) {

5

誤字

2017/06/02 08:39

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -60,7 +60,6 @@
60
60
  val item = getItem(position)
61
61
  if (choiceList.contains(item)) {
62
62
  choiceList.remove(item)
63
- choiceList.add(item)
64
63
  } else {
65
64
  choiceList.add(item)
66
65
  }

4

誤字

2017/06/02 08:34

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -57,6 +57,7 @@
57
57
 
58
58
 
59
59
  fun choice(position: Int) {
60
+ val item = getItem(position)
60
61
  if (choiceList.contains(item)) {
61
62
  choiceList.remove(item)
62
63
  choiceList.add(item)

3

修正

2017/06/02 08:33

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -35,7 +35,7 @@
35
35
 
36
36
  private val choiceList: HashSet<Cursor>
37
37
 
38
- init {
38
+ init {
39
39
  this.choiceList = HashSet<Cursor>()
40
40
  }
41
41
 

2

修正

2017/06/02 08:33

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -32,6 +32,13 @@
32
32
 
33
33
  ```kotlin
34
34
  class ImageCursorAdapter(val context: Context?, c: Cursor?, flags: Int) : CursorAdapter(context, c, flags) {
35
+
36
+ private val choiceList: HashSet<Cursor>
37
+
38
+ init {
39
+ this.choiceList = HashSet<Cursor>()
40
+ }
41
+
35
42
  override fun newView(context: Context?, cursor: Cursor?, parent: ViewGroup?): View? {
36
43
  //省略
37
44
  }
@@ -48,6 +55,17 @@
48
55
  return super.getItem(position) as Cursor
49
56
  }
50
57
 
58
+
59
+ fun choice(position: Int) {
60
+ if (choiceList.contains(item)) {
61
+ choiceList.remove(item)
62
+ choiceList.add(item)
63
+ } else {
64
+ choiceList.add(item)
65
+ }
66
+ notifyDataSetChanged()
67
+ }
68
+
51
69
  }
52
70
 
53
71
  ```

1

誤字

2017/06/02 08:32

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -23,7 +23,7 @@
23
23
  listAdapter = imageCursorAdapter
24
24
  }
25
25
  override fun onLoaderReset(loader: Loader<Cursor>?) {
26
- imageCursorAdapter!!.swapCursor(null)
26
+
27
27
  }
28
28
  })
29
29
  }
@@ -57,4 +57,4 @@
57
57
  テスト: ゲット2android.content.ContentResolver$CursorWrapperInner@3cb38fd
58
58
  テスト: ゲット3android.content.ContentResolver$CursorWrapperInner@3cb38fd
59
59
 
60
- 任意のpositionのcursorのデータを取得したい場合どのようにすればよいか教えてください。
60
+ 任意のpositionのcursorのデータ(レコード?)を取得したい場合どのようにすればよいか教えてください。