diff --git a/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java b/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java index 1437f35..cd8727d 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java @@ -54,7 +54,7 @@ LocationManager locationManager; private ArrayList listeners = new ArrayList<>(); private HashMap categories; - ArrayList checkedList = new ArrayList<>(); + private ArrayList checkedList = new ArrayList<>(); HashMap menuItemMap = new HashMap<>(); ImageButton playbutton; ImageButton stopbutton; @@ -244,14 +244,16 @@ getMenuInflater().inflate(R.menu.nav_drawer_menu, menu); //カテゴリーの数だけitemを定義 + int id=0; for(Category category : categories.values()){ String name = category.getName(); String cid = category.getcId(); - MenuItem newItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, name); + MenuItem newItem = menu.add(Menu.NONE, id, Menu.NONE, name); menuItemMap.put(newItem.getItemId(),cid); newItem.setCheckable(true); newItem.setChecked(true); checkedList.add(cid); + id++; } return true; } @@ -263,9 +265,9 @@ item.setChecked(!item.isChecked()); if(item.isChecked()){ - checkedList.remove(cid); - }else{ checkedList.add(cid); + }else{ + checkedList.remove(cid); } return super.onOptionsItemSelected(item); }