8
7

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.

AndroidのActionBarにメニューボタンが表示されるかどうかを取得する

8
Posted at

Android 4.0以降のスマートフォンでは、ハードキーにメニューボタンが付いているかいないかで、ActionBarにメニューボタンが追加されるかどうかが変わってしまいます。もしもActionBar非表示のUIを採用していても、メニューボタンの有無は割と重要だと思います。今回は、ハードのメニューボタンが存在するか、というよりActionBarにメニューが追加されるかどうかを取得します。といっても難しいものではなく、Acitivity上で
ViewConfiguration.get(this).hasPermanentMenuKey();
を呼び出すだけです。ViewConfiguration#hasPermanentMenuKey()はboolean型で、端末にメニューボタンがある場合はtrueを、ない場合はfalseを返すようです。

8
7
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
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?