question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Provide a PopupMenu component

See original GitHub issue

Currently there is no way to specify an overflow menu icon for Navigator.NavigationBar (or is there?). I can add a custom button, sure, but I cannot find a way to show a menu. Does such a functionality exist?

The Menu component is widely used on Android, and it’ll be awesome to have it.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:53 (28 by maintainers)

github_iconTop GitHub Comments

15reactions
chirag04commented, Mar 28, 2016

context popupMenu is already exposed on UIManager. I have a small wrapper that adds a vertical hamburger menu and shows the popup on it like the youtube app.

import React from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';

import styles from './styles';

const {
  View,
  UIManager,
  findNodeHandle,
  TouchableOpacity,
} = React;

const ICON_SIZE = 24;

class PopupMenu extends React.Component {
  handleShowPopupError = () => {
    // show error here
  };

  handleMenuPress = () => {
    const { actions, onPress } = this.props;

    UIManager.showPopupMenu(
      findNodeHandle(this.refs.menu),
      actions,
      this.handleShowPopupError,
      onPress,
    );
  };

  render() {
    return (
      <View>
        { this.props.children }
        <TouchableOpacity onPress={this.handleMenuPress} style={styles.touchableContainer}>
          <Icon
            name="android-more-vertical"
            size={ICON_SIZE}
            color={'grey'}
            ref="menu"
          />
        </TouchableOpacity>
      </View>
    );
  }
}

PopupMenu.propTypes = {
  actions: React.PropTypes.array.isRequired,
  onPress: React.PropTypes.func.isRequired,
  children: React.PropTypes.object.isRequired,
};

export default PopupMenu;
<PopupMenu actions=['1', '2'] onPress={() => { // }}>
      <YourListItem .... />
</PopupMenu>
4reactions
wvengencommented, Feb 17, 2016

@terrysahaidak That’s a good point. As a somewhat ugly workaround I’m now using a Picker with an opacity of zero and a fixed width, positioning it on top of an icon (though not in a NavigationBar). I’d love it to be possible to specify an element for rendering the Picker button, perhaps something for a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Popup Menu in Android With Example - GeeksforGeeks
In android, Menu is an important part of the UI component which is used to provide some common functionality around the application.
Read more >
PopupMenu - Android Developers
Interface responsible for receiving menu item click events if the items themselves do ... Google uses cookies to deliver its services, to personalize...
Read more >
Android Popup Menu with Examples - Tutlane
In android, Popup Menu displays a list of items in a modal popup window that is anchored to the view. The popup menu...
Read more >
Menus and Popups | CodePath Android Cliffnotes
PopupMenu - A modal menu that is anchored to a particular view within an activity. The menu appears below that view when it...
Read more >
How to Create Android Popup Menu Programmatically and ...
Hi and welcome to another tutorial from CodingDemos :)In this tutorial, you will learn how to create Android popup menu or floating menu ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found