質問編集履歴

3

MakeQuizActivityの追記

2020/05/18 03:46

投稿

j06110611
j06110611

スコア54

test CHANGED
File without changes
test CHANGED
@@ -250,6 +250,104 @@
250
250
 
251
251
 
252
252
 
253
+ ```MakeQuizActivity
254
+
255
+ ublic class MakeQuizActivity extends AppCompatActivity {
256
+
257
+ public static Map<String,String> mapTitle = new HashMap<>();
258
+
259
+ public static Map<String,String> mapQuiz = new HashMap<>();
260
+
261
+ public static Map<String,String> mapAnswer = new HashMap<>();
262
+
263
+ public static ArrayList titleList = new ArrayList<String>();
264
+
265
+ public static ArrayList quizList = new ArrayList<String>();
266
+
267
+ public static ArrayList answerList = new ArrayList<String>();
268
+
269
+
270
+
271
+ @Override
272
+
273
+ protected void onCreate(Bundle savedInstanceState) {
274
+
275
+ super.onCreate(savedInstanceState);
276
+
277
+ setContentView(R.layout.activity_make_quiz);
278
+
279
+
280
+
281
+ Button button2 = (Button)findViewById(R.id.makeQuiz_Button2);
282
+
283
+ button2.setOnClickListener(new View.OnClickListener() {
284
+
285
+ @Override
286
+
287
+ public void onClick(View v) {
288
+
289
+ Intent intent = new Intent(MakeQuizActivity.this,com.test.quizmaker.MainActivity.class);
290
+
291
+ String strTitle = ((EditText)findViewById(R.id.editText)).getText().toString();
292
+
293
+ String strQuiz = ((EditText)findViewById(R.id.editText2)).getText().toString();
294
+
295
+ String strAnswer = ((EditText)findViewById(R.id.editText3)).getText().toString();
296
+
297
+ PreferenceManager.saveInt(MainActivity.count);
298
+
299
+ PreferenceManager.saveString(strTitle, DataKeys.TITLE, String.valueOf(MainActivity.count));
300
+
301
+ titleList.add(strTitle);
302
+
303
+ mapTitle.put(DataKeys.TITLE.getValue() + String.valueOf(MainActivity.count),strTitle);
304
+
305
+ PreferenceManager.saveString(strQuiz, DataKeys.QUIZ, String.valueOf(MainActivity.count));
306
+
307
+ quizList.add(strQuiz);
308
+
309
+ mapQuiz.put(DataKeys.QUIZ.getValue() + String.valueOf(MainActivity.count),strQuiz);
310
+
311
+ PreferenceManager.saveString(strAnswer, DataKeys.ANSWER, String.valueOf(MainActivity.count));
312
+
313
+ answerList.add(strAnswer);
314
+
315
+ mapAnswer.put(DataKeys.ANSWER.getValue() + String.valueOf(MainActivity.count),strAnswer);
316
+
317
+ String title = PreferenceManager.sp.getString(DataKeys.TITLE.getValue() + String.valueOf(MainActivity.count), "Nothing");
318
+
319
+ String quiz = PreferenceManager.sp.getString(DataKeys.QUIZ.getValue() + String.valueOf(MainActivity.count),"Nothing");
320
+
321
+ String answer = PreferenceManager.sp.getString(DataKeys.ANSWER.getValue() + String.valueOf(MainActivity.count),"Nothing");
322
+
323
+ intent.putExtra("INPUT_TITLE", title);
324
+
325
+ intent.putExtra("INPUT_QUIZ",quiz);
326
+
327
+ intent.putExtra("INPUT_ANSWER",answer);
328
+
329
+ MainActivity.count ++;
330
+
331
+ Log.v("Debug","countの値:" + String.valueOf(MainActivity.count));
332
+
333
+ setResult(RESULT_OK, intent);
334
+
335
+ finish();
336
+
337
+ }
338
+
339
+ });
340
+
341
+ }
342
+
343
+ }
344
+
345
+
346
+
347
+ ```
348
+
349
+
350
+
253
351
  ```PreferenceManager
254
352
 
255
353
  public class PreferenceManager{

2

補足

2020/05/18 03:46

投稿

j06110611
j06110611

スコア54

test CHANGED
File without changes
test CHANGED
@@ -6,6 +6,14 @@
6
6
 
7
7
  →多分上から順に削除されてしまう。
8
8
 
9
+ ### 削除している部分
10
+
11
+ ```MainActivity
12
+
13
+ adapter.remove(MakeQuizActivity.titleList.get(i));
14
+
15
+ ```
16
+
9
17
  ### 知りたいこと
10
18
 
11
19
  解決策やヒントをください。お願いします!

1

補足

2020/05/17 15:07

投稿

j06110611
j06110611

スコア54

test CHANGED
File without changes
test CHANGED
@@ -1,5 +1,7 @@
1
1
  ### 現状
2
2
 
3
+ 全項目選択されていたら、特に不具合は起きず全削除される。
4
+
3
5
  3つ項目を作って1つ目・3つ目にチェックすると、1つ目と2つ目が削除される
4
6
 
5
7
  →多分上から順に削除されてしまう。