0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PopupMenu の要素を動的に追加する

Posted at

わざわざ記事にすることでもないかもしれないですが、 PopupMenu を使った際に menu リソース以外からも要素を作成する方法の備忘録を自分ように残します。

やり方

以下のコードの popupMenu.menu.add("文字列") を行うことで好きな数だけ要素を増やすことができます。

val popupMenu = PopupMenu(this, target)
popupMenu.menu.add("テスト1")
popupMenu.menu.add("テスト2")
popupMenu.menu.add("テスト3")
popupMenu.show()
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?