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 5 years have passed since last update.

BottomNavigationViewのアイテムを動的に隠す

Posted at

はじめに

業務において「条件に応じてBottomNavigationViewのアイテムを隠す」
という要件があって調べたので備忘録として残しておきます。

実装方法

最初はVisibilityを触って非表示にする方法を調べていましたが、remoteItemを使うのが正解のようです。

mBottomNavigationView.getMenu().removeItem(R.id.item_name);

結果

「カリキュラム」というメニューを隠してみました。

通常時

通常はBottomNavigationが4つのメニューアイテムを持っています。
image.png

removeItemで隠した時

このようにカリキュラムのメニューが隠れ、3つのメニューアイテムとなりました。
image.png

参考

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?