Android Question AddMenuItem ???

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
Long ago there was a quick and dirty Android way for adding a menu that would pop up when the dedicated menu button (at bottom, next to the dedicated home button) was pressed.

B4A provides a method AddMenuItem that would add clickable items to this menu.

Since that time Android has decided to make this dedicated button the "Recently Used" button. A long click will still open the menu, but it's probably not preferred thing to do.

I have seen Erel's StdActionBar and TabStripView.

I would prefer not to dedicate screen real estate to a button or tab bar, but rather have a transparent button that I could overlay and would open a list menu upon click. Something like the horizontal bars (without the text) in the upper left of the image below or the dots at the upper right, without the dedicated blue bar.

upload_2017-1-14_14-25-30.png


Is there something available for B4A: class, custom view, etc., that does this – creates a pop-up list menu of clickable items upon a button press?

Thanks,
Barry.
 

Attachments

  • upload_2017-1-14_14-24-45.png
    upload_2017-1-14_14-24-45.png
    6.5 KB · Views: 376

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can still use Activity.AddMenuItem.

If the device doesn't have a menu button (most device do not have one) then a three dots button will show in the top right corner of the action bar. Otherwise the menu will be opened by clicking on the menu button. I guess that your device is considered a device with a menu button so you don't see the three dots button.

Note that StdActionBar and TabStrpViewPager are not related to the menu.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
You can still use Activity.AddMenuItem.

If the device doesn't have a menu button (most device do not have one) then a three dots button will show in the top right corner of the action bar. Otherwise the menu will be opened by clicking on the menu button. I guess that your device is considered a device with a menu button so you don't see the three dots button.

Note that StdActionBar and TabStrpViewPager are not related to the menu.

I also have a menu button (galaxy s 5)
And my menu button also turned into "recentley used"..

But i do see the 3 dots if showtitle is set to true so also on device with a menu button you still get the 3 dots on the right top corner when you set the "showtitle" attribute to true.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
Thanks for the responses.

I just need something really simple. I sometimes have an App where you have to display stuff full-screen, but it would be really handy to have a pop-up menu without taking up screen real estate.

I put something simple together I call it Simple Menu. The source and an example is included in the attached Zip file.

upload_2017-1-16_18-7-53.png


The menu adds one unique feature – a checkbbox for setting on/off properties.

Barry.
 

Attachments

  • SimpMenu.zip
    311.9 KB · Views: 381
Upvote 0

corwin42

Expert
Licensed User
Longtime User
If you use AppCompat in your app you can use AppCompat library to create a Popup Menu.

If you don't use AppCompat you can use StdActionBarHelper library for the same Popup Menu (you don't need to use an ActionBar for the Popup. It can be displayed above any other View, even a Dummy View).
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0

corwin42

Expert
Licensed User
Longtime User
if you want to have different views in your popup menu like checkbox and buttons you will need to make your own.
PopupMenu object from AppCompat and StdActionbarHelper should support checkboxes.
 
Upvote 0
Top