質問編集履歴

5

2017/08/28 07:57

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  //UPDATE処理完了 詳細画面へ遷移
38
38
 
39
- Intent intent = new Intent(getApplication(),Wishlist_Item_DetailActivity.class);
39
+ Intent intent = new Intent(getApplication(),Item_DetailActivity.class);
40
40
 
41
41
  startActivity(intent);
42
42
 

4

2017/08/28 07:57

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -14,115 +14,11 @@
14
14
 
15
15
 
16
16
 
17
-
18
-
19
- ```java
20
-
21
- //編集完了ボタンを取得
22
-
23
- findViewById(R.id.update_finish).setOnClickListener(new View.OnClickListener() {
24
-
25
-
26
-
27
- //編集完了ボタンが押されたときの処理
28
-
29
- @Override
30
-
31
- public void onClick(View v) {
32
-
33
-
34
-
35
- //編集データを各変数に代入
36
-
37
- EditText title_text = (EditText) findViewById(R.id.EditTitle);
38
-
39
- EditText comment_text = (EditText) findViewById(R.id.EditDescription);
40
-
41
- String update_date = dateFormat();
42
-
43
-
44
-
45
- //keyとvalueとして使えるクラス
46
-
47
- HashMap<String, String> item = new HashMap<String, String>();
48
-
49
-
50
-
51
- //連想配列になってる
52
-
53
- item.put("title", title_text.getText().toString());
54
-
55
- item.put("comment", comment_text.getText().toString());
56
-
57
- item.put("update_date", update_date.toString());
58
-
59
-
60
-
61
- ActiveAndroid.beginTransaction();
62
-
63
- try {
64
-
65
-
66
-
67
- wishlistModel targetRecord = new Select().from(wishlistModel.class).where("Id = ?", record_id).executeSingle();
68
-
69
- targetRecord.title = item.get("title");
70
-
71
- targetRecord.comment = item.get("comment");
72
-
73
- targetRecord.update_date = item.get("update_date");
74
-
75
-
76
-
77
- targetRecord.save();
78
-
79
-
80
-
81
- //UPDATE処理完了 詳細画面へ遷移
82
-
83
- Intent intent = new Intent(getApplication(),Wishlist_Item_DetailActivity.class);
84
-
85
- startActivity(intent);
86
-
87
-
88
-
89
- //intentの挙動がおかしいから後で見る。エラーで落ちたりはしない。
90
-
91
-
92
-
93
- ActiveAndroid.setTransactionSuccessful();
94
-
95
- } finally {
96
-
97
- ActiveAndroid.endTransaction();
98
-
99
-
100
-
101
-
102
-
103
- }
104
-
105
- }
106
-
107
-
108
-
109
- });
110
-
111
- ```
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
17
  エラーは下記です。
120
18
 
121
19
 
122
20
 
123
21
  編集完了ボタンを押すとこうなります。
124
-
125
- ![イメージ説明](11e52f5aef4a6b112a2bea862093ff79.png)
126
22
 
127
23
 
128
24
 

3

2017/08/28 07:56

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -184,16 +184,6 @@
184
184
 
185
185
 
186
186
 
187
-
188
-
189
- なので詳細画面にて下記を条件分岐を追加。
190
-
191
-
192
-
193
- ![イメージ説明](3d6816b4a42f020ebfaeb99b736a07b8.png)
194
-
195
-
196
-
197
187
  nullエラーということなので、
198
188
 
199
189
  intentがnullならその処理を通さないようにしたのですが、
@@ -205,3 +195,9 @@
205
195
 
206
196
 
207
197
  この場合、どうしたら良いでしょうか?
198
+
199
+
200
+
201
+ ※当質問は、務めていた会社での課題に行き詰まった内容を投稿したものである。
202
+
203
+ 質問に記載していた画像は情報漏洩の観点から削除した。

2

ウェdw

2017/08/28 07:54

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -147,3 +147,61 @@
147
147
 
148
148
 
149
149
  をコメントするとエラーは起きません。
150
+
151
+
152
+
153
+
154
+
155
+ 追記:
156
+
157
+
158
+
159
+ 一覧画面で表示してるレコードのidをintentで詳細画面に渡す。
160
+
161
+
162
+
163
+ 詳細画面で受け取ったidを基に該当レコード抽出。
164
+
165
+ 編集ボタンを押したらそのidをintentで編集画面に渡す。
166
+
167
+
168
+
169
+ 編集画面で受け取ったidを基に該当レコード抽出。
170
+
171
+ EditTextにセットして編集可能にする。
172
+
173
+ 編集完了ボタンを押したらレコード更新処理して、詳細画面に遷移。
174
+
175
+
176
+
177
+ 詳細画面に移動、、、ん?
178
+
179
+ 詳細画面で受け取ってるintentに何もセットなれとらんがな。
180
+
181
+
182
+
183
+ ってのがエラー内容でした。
184
+
185
+
186
+
187
+
188
+
189
+ なので詳細画面にて下記を条件分岐を追加。
190
+
191
+
192
+
193
+ ![イメージ説明](3d6816b4a42f020ebfaeb99b736a07b8.png)
194
+
195
+
196
+
197
+ nullエラーということなので、
198
+
199
+ intentがnullならその処理を通さないようにしたのですが、
200
+
201
+ intentがnullじゃないとき(つまり一覧画面から遷移してきた時)はif内通るようにしてるのに
202
+
203
+ record_idが見つけられんと言われてしまいます。
204
+
205
+
206
+
207
+ この場合、どうしたら良いでしょうか?

1

っs

2016/11/16 13:05

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -131,3 +131,19 @@
131
131
 
132
132
 
133
133
  何がダメなのでしょうか?
134
+
135
+
136
+
137
+
138
+
139
+ ちなみに
140
+
141
+ //UPDATE処理完了 詳細画面へ遷移
142
+
143
+ Intent intent = new Intent(getApplication(),Wishlist_Item_DetailActivity.class);
144
+
145
+ startActivity(intent);
146
+
147
+
148
+
149
+ をコメントするとエラーは起きません。