5 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.

    Reply
  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”

    Reply
    • 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!

      Reply

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 *