lupidan / PopoverView

A Popover Controller for Android Tablets. It's an easy solution to simulate an iOS UIPopoverController

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PopoverView from an ActionBar MenuItem

jeremymedford opened this issue · comments

My apologies for being a little vague in this first question, but I am not very far along.

I would like to display the PopoverView from an ActionBar MenuItem, and am not getting the desired results. I am using the ActionBarSherlock library.

Here is a snippet of code where I am attempting to set up the PopoverView.

 @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if (item.getItemId() == android.R.id.home) {

            //...
        } else if (item.getItemId() == R.id.action_notifications) {         

            PopoverView popoverView = new PopoverView(this, R.layout.popover_notifications_view);
            popoverView.setDelegate(this);

            RelativeLayout rootView = (RelativeLayout)findViewById(R.id.rootLayout);

            popoverView.setContentSizeForViewInPopover(new Point(640, 680));
            View v = (View)findViewById(R.id.action_notifications);

            popoverView.showPopoverFromRectInViewGroup(rootView, PopoverView.getFrameForView(v), PopoverView.PopoverArrowDirectionAny, true);

            return(true);

        }

        return super.onOptionsItemSelected(item);
    }

I feel like the view used for PopoverView.getFrameForView(v) is wrong. I'm trying to reference the globe item in the screenshot. I am getting the PopoverView underneath the ActionBar like this:

screenshot_2014-01-09-10-48-45

Any direction or sample would be very much appreciated.
Jeremy

If you are trying to show the PopoverView from the globe item, I think the main problem there is that the ActionBar is on top of your rootView. It actually looks like the coordinates to show it are correct.

The PopoverLayout will be added as a child view of the ViewGroup you input in showPopoverFromRectInViewGroup (in your case rootView). If that view is below the action bar, this behaviour is expected.