Alternative view method. Menu*

Asked

Viewed 39 times

2

I am beginner with Android programming and am following the book "Google Android" (2012), of Code House.

I arrived at a part where you should create "menus" using the functions present in android.view.Menu*, and the expected result should be something like that of the image below:

Exemplo do Livro However, when running on my device (Android 5.1.1) the menu does not appear and no error is triggered.

I did some research and I came to the conclusion that this occurs because the newer versions of android no longer have the "options" button (or something like that).

Well, I wonder if there are alternative ways to represent these menus, since during the course, new implementations will be made using these menus.

Thank you for your attention!

Michael.

  • put the code of what you have already done there to get an idea of what you need

  • Probably if you hold(long click) the minimize button of your navigation bar, the menu will appear.

  • @Armandomarquessobrinho - It’s a very simple code, but I’m not going to warm my head about it. As it is just for learning, I will replace the view.Menu with a Alertdialog (famous gambiarra). Acklay - I tried, but it doesn’t work. Thank you!

  • Android is in you counted change, if it is starting, do not study by old material.

  • @ramaral I bought the book from the code house thinking it was updated, but it seems I was wrong. Anyway, it is enough to give me a basis, nothing that other research does not solve to improve me. Can you recommend something?

  • No. I usually go to the Internet. I always have attention to the date of publication and I see more than one on the same subject. I don’t know if this is your case but before Android comes Java, it is necessary to master it minimally to make learning Android easier.

Show 1 more comment

1 answer

1


This Feature really changed and today Android does not behave that way. This can be checked here:

https://developer.android.com/guide/topics/ui/menus.html

The options menu is where you should include actions and other options that are relevant to the current activity context, such as "Search", "Write e-mail" and "Settings".

The location where items in the options menu appear on the screen depends on the version in which the application was developed:

If you have developed the app for Android 2.3.x (Level API 10) or lower, the contents of the options menu will appear in the bottom of the screen, when the user presses the Menu button, such as shown in figure 1. When opened, the first visible part is the menu icons, which has up to six menu items. If the menu includes more than six items, Android will put the sixth item and the rest in a menu floating that the user can open by selecting More. If you developed the app for Android 3.0 (Level 11 API) or top, options menu items are available in the apps. By default, the system positions all items in actions additional, which the user can reveal with the additional actions icon on the right side of the app bar (or by pressing the Menu button on the device, if available). To enable quick access to actions important, it is possible to promote some items to appear in the bar of apps adding android:showAsAction="ifRoom" to the elements corresponding (see figure 2). For more information about action items and other bar behaviors apps, see the Add app bar class.

Another point to consider is that only 1.7% of Hojem smartphones use version 2.3 of Android (Gingerbread), IE it would be more advisable you update your study material, I can suggest even the Android website or other options

inserir a descrição da imagem aqui

Other links to more current Android materials:

  • @diegofm The chart was taken from the Android website (https://developer.android.com/about/dashboards/index.html). It was measured in 2016, but I think my point is still valid.

  • In fact, the nougat marketshare has not yet been lifted, my mistake then.

  • 1

    Okay, so that’s what I figured...!

  • @Rafaellucena I still have to get used to this posting model. I have already signaled as requested. Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.