回答編集履歴

8

コード修正

2018/10/31 07:45

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -98,9 +98,9 @@
98
98
 
99
99
  {
100
100
 
101
- groupList = new List<IDictionary<string, object>>();
101
+ groupList = new JavaList<IDictionary<string, object>>();
102
102
 
103
- childList = new List<IList<IDictionary<string, object>>>();
103
+ childList = new JavaList<IList<IDictionary<string, object>>>();
104
104
 
105
105
 
106
106
 

7

コード修正

2018/10/31 07:45

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -156,6 +156,6 @@
156
156
 
157
157
  }
158
158
 
159
- }
159
+ }
160
160
 
161
161
  ```

6

追記

2018/10/31 07:09

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -43,3 +43,119 @@
43
43
 
44
44
 
45
45
  あと、ダイアログで入力した値を使うのであれば、この処理は、`SetPositiveButton`の`handler`内でやるべきです。
46
+
47
+
48
+
49
+ ---
50
+
51
+
52
+
53
+ リストデータの保存は、`OnSaveInstanceState`で`PutSerializable`で行い、`OnCreate`で、`GetSerializable`で取得します。
54
+
55
+
56
+
57
+ ```C#
58
+
59
+ public class MainActivity : Activity
60
+
61
+ {
62
+
63
+ private JavaList<IDictionary<string, object>> groupList;
64
+
65
+ private JavaList<IList<IDictionary<string, object>>> childList;
66
+
67
+
68
+
69
+ protected override void OnCreate(Bundle savedInstanceState)
70
+
71
+ {
72
+
73
+ base.OnCreate(savedInstanceState);
74
+
75
+
76
+
77
+ // Set our view from the "main" layout resource
78
+
79
+ SetContentView(Resource.Layout.Main);
80
+
81
+
82
+
83
+ ...
84
+
85
+
86
+
87
+ if (savedInstanceState != null)
88
+
89
+ {
90
+
91
+ groupList = savedInstanceState.GetSerializable(nameof(groupList)).JavaCast<JavaList<IDictionary<string, object>>>();
92
+
93
+ childList = savedInstanceState.GetSerializable(nameof(childList)).JavaCast<JavaList<IList<IDictionary<string, object>>>>();
94
+
95
+ }
96
+
97
+ else
98
+
99
+ {
100
+
101
+ groupList = new List<IDictionary<string, object>>();
102
+
103
+ childList = new List<IList<IDictionary<string, object>>>();
104
+
105
+
106
+
107
+ ...
108
+
109
+ }
110
+
111
+
112
+
113
+ SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(
114
+
115
+ this,
116
+
117
+ groupList,
118
+
119
+ Android.Resource.Layout.SimpleExpandableListItem1,
120
+
121
+ new string[] { "GROUPE_TITLE" },
122
+
123
+ new int[] { Android.Resource.Id.Text1 },
124
+
125
+ childList,
126
+
127
+ Android.Resource.Layout.SimpleExpandableListItem2,
128
+
129
+ new string[] { "CHILD_TITLE" },
130
+
131
+ new int[] { Android.Resource.Id.Text2 }
132
+
133
+ );
134
+
135
+ memolist.SetAdapter(adapter);
136
+
137
+
138
+
139
+ ...
140
+
141
+ }
142
+
143
+
144
+
145
+ protected override void OnSaveInstanceState(Bundle outState)
146
+
147
+ {
148
+
149
+ base.OnSaveInstanceState(outState);
150
+
151
+
152
+
153
+ outState.PutSerializable(nameof(groupList), groupList.JavaCast<ISerializable>());
154
+
155
+ outState.PutSerializable(nameof(childList), childList.JavaCast<ISerializable>());
156
+
157
+ }
158
+
159
+ }
160
+
161
+ ```

5

コード修正

2018/10/31 07:08

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  var newGroupElement = new JavaDictionary<string, object>();
22
22
 
23
- newGroupElement.Add("GROUPE_LIST", notename.Text);
23
+ newGroupElement.Add("GROUPE_TITLE", notename.Text);
24
24
 
25
25
  groupList.Add(newGroupElement);
26
26
 

4

コード修正

2018/10/31 02:51

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- if (!string.IsNullOrEmpty(notename.Text)
17
+ if (!string.IsNullOrEmpty(notename.Text))
18
18
 
19
19
  {
20
20
 

3

コード修正

2018/10/29 02:44

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -10,17 +10,31 @@
10
10
 
11
11
  {
12
12
 
13
- var newGroupElement = new JavaDictionary<string, object>();
13
+ Toast.MakeText(this, notename.Text, ToastLength.Short).Show();
14
14
 
15
- newGroupElement.Add("GROUPE_LIST", notename.Text);
15
+
16
16
 
17
- groupList.Add(newGroupElement);
17
+ if (!string.IsNullOrEmpty(notename.Text)
18
18
 
19
- adapter.NotifyDataSetChanged();
19
+ {
20
20
 
21
+ var newGroupElement = new JavaDictionary<string, object>();
21
22
 
23
+ newGroupElement.Add("GROUPE_LIST", notename.Text);
22
24
 
25
+ groupList.Add(newGroupElement);
26
+
23
- Toast.MakeText(this, notename.Text, ToastLength.Short).Show();
27
+ adapter.NotifyDataSetChanged();
28
+
29
+ }
30
+
31
+ else
32
+
33
+ {
34
+
35
+ // 未入力エラー
36
+
37
+ }
24
38
 
25
39
  });
26
40
 

2

コード修正

2018/10/29 02:44

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
 
22
22
 
23
- Toast.MakeText(this, notename.Text, ToastLength.Short).Show());
23
+ Toast.MakeText(this, notename.Text, ToastLength.Short).Show();
24
24
 
25
25
  });
26
26
 

1

コード修正

2018/10/29 02:41

投稿

f-miyu
f-miyu

スコア1625

test CHANGED
@@ -6,13 +6,23 @@
6
6
 
7
7
  ```C#
8
8
 
9
- var newGroupElement = new JavaDictionary<string, object>();
9
+ dlg.SetPositiveButton("OK", (s, a) =>
10
10
 
11
- newGroupElement.Add("GROUPE_LIST", notename.Text);
11
+ {
12
12
 
13
- groupList.Add(newGroupElement);
13
+ var newGroupElement = new JavaDictionary<string, object>();
14
14
 
15
+ newGroupElement.Add("GROUPE_LIST", notename.Text);
16
+
17
+ groupList.Add(newGroupElement);
18
+
15
- adapter.NotifyDataSetChanged();
19
+ adapter.NotifyDataSetChanged();
20
+
21
+
22
+
23
+ Toast.MakeText(this, notename.Text, ToastLength.Short).Show());
24
+
25
+ });
16
26
 
17
27
  ```
18
28