Hi everyone! EndLessMind here with another great tutorial!
In this tutorial, we are going to make a PopupMenu, ContextMenu and Custom PopupWindow at once.

Introduction
Ever wanted a popup-menu that expands from a view, or a Popup-window that's easy to use?
Well, now i'm going to share how to do it.

In native Android, there is a PopupWindow, but it's not really easy to use it.
By creating some fairly simple code, we can make use if this function with only a few lines of code.

Creating the project
Okey, so lets start out with creating the project

Lets first create a new Android project and name it "com.example.mywindow"
and the build target for Android 2.1, and next set the following:
Application name: Tutorial Sound Custom Window
Package name: com.example.mywindow
Create Activity (Checked): MainActivity
Then press Finish.

Making use of the PopupWindow
Okay, so now we will be making a class named PopupWindows
In that class, we'll add this code:

So, i guess you are getting a bunch of error right now. Don't worry, we'll get there.
This class uses the PopupWindows-class to create, what i call, a QuickAction-popup.
This is not just a Window, this also has a pointer that points to a View of our choice.
This is a bit more complex code, that calculate where to show the pointer/arrow, has animations and more.
It has a bit of documentation, but i would fill this tutorial if i was to explain each part.
If you have any question, please just ask.

Moving on..

A little class
Now we are going to create the holder for the items in the QuickAction-popup, classed ActionItems.
Create a new class and name it ActionItem.
This is our code for that one:

This code, is well documented, this is because i want to save your time.
But basically, it holds the values that will be shown in the QuickAction-popup.

Animations and styles
This tutorial requires 17(!) animations, so to save time and space, i'll just write their name and then the xml-code.
In you'r res-directory, create a folder called "anim". This is where all the animations are going.

Layouts
Wow, it's a lot if animations. Well, we are not done with the xml yet.
Next up we have the layouts, we have 6 layouts + changes in the activity_main.xml.
For the 6 new layouts, i'm going to do the same as with the animations.

So, what do we have here?
Well, we get the layout and then listeners to the buttons.
Also, we create 2 ActionItems and adds them to the QuickAction.
We also set the OnActionItemClickListener to the QuickAction.

In the btn1_Click, we display the QuickAction.
In the btn2_Click, we create a PopupWindow, with a onclickListener for the close-button, and then shows it.