- [Android アプリにメニューを追加する https://qiita.com/Uchikoba/items/d2e80c33a3334825bfc4]
- https://developer.android.com/guide/topics/ui/menus?hl=ja
- https://developer.android.com/guide/topics/resources/menu-resource?hl=ja
- メニューの外だしは、showAsActionで設定する
- 古いものだと指定方法が違うらしい https://qiita.com/KeithYokoma/items/e7c7b960a0fb1d983355
- menuリソースにxmlを足す
- Activityにメソッドを足す
Last active
May 24, 2020 06:18
-
-
Save taktamur/990b22be1bd871bbfb970387a47a2d05 to your computer and use it in GitHub Desktop.
Screapboxから:Android menuリソース
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 右上のメニューの組み立て | |
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | |
menuInflater.inflate(R.menu.list_view_menu, menu) | |
return super.onCreateOptionsMenu(menu) | |
} | |
override fun onOptionsItemSelected(item: MenuItem?): Boolean { | |
return when(item?.itemId){ | |
R.id.menuItem1 -> { | |
// adapterにinsertしたら画面が更新される | |
// これはinserの中で、notifyDataSetChanged()が呼ばれているから | |
adapter.insert("ADD"+adapter.count,0) | |
true | |
} | |
R.id.menuItem2 -> { | |
adapter.remove(adapter.getItem(0)) | |
true | |
} | |
else->{ | |
super.onOptionsItemSelected(item) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment