6 replies
  1. Lance Johnson says:

    Well done Sr. You really hit the mark on this one. I would just add one thing to support tooltip on long press. I got that via:

    TooltipCompat.setTooltipText(rootView, alertMenuItem .getTitle())

    in onPrepareOptionsMenu when you add the other click listener.

  2. Faris M S says:

    Good Article, Thanks for writing this.
    i have tried this one in my Fragment, But it is getting error for invoking custom control
    “java.lang.NullPointerException: Attempt to invoke virtual method ‘android.view.View android.widget.FrameLayout.findViewById(int)’ on a null object reference”

    • Erin Duff
      Erin Duff says:

      Hi Faris,

      Without looking at your code there are a number of things that could cause that. My top guesses are: your menu items might not have the same id names, and you might not have called setHasOptionsMenu(true).

      I can say for certain that the FrameLayout you are calling findViewById() on is null and that is, somehow, the cause of the issue.
      This example uses Activity instead of Fragment, you’ll need to make the appropriate adjustments to the implementation.

      Hope this helps!

  3. Pravin Gaikwad says:

    Thanks. It is really very very helpful.
    I faced issues while showing menu group items (submenu of menu-item whom I have passed actionLayout view). So, I ended up showing PopupMenu on click of menu-item.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *