[Free] Popup Extension - An extension to create popup menu

Code was already mentioned :arrow_down:

Raw Code :
package com.faraz.popup;

import android.app.Activity;

import android.content.Context;

import com.google.appinventor.components.annotations.*;

import com.google.appinventor.components.annotations.SimpleFunction;

import com.google.appinventor.components.annotations.SimpleProperty;

import com.google.appinventor.components.common.ComponentCategory;

import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;

import com.google.appinventor.components.runtime.ComponentContainer;

import com.google.appinventor.components.runtime.EventDispatcher;

import com.google.appinventor.components.runtime.AndroidViewComponent;

import android.widget.PopupMenu;

import android.view.View;

import android.widget.AdapterView;

import android.view.MenuItem;

import java.util.List;


        version = 1,

        description = "",

        category = ComponentCategory.EXTENSION,

        nonVisible = true,

        iconName = "")

@SimpleObject(external = true)

public class Popup extends AndroidNonvisibleComponent {

    private Context context;

    private Activity activity;

    private PopupMenu popup;

    public Popup(ComponentContainer container){


        this.activity = container.$context();

        this.context = container.$context();


    @SimpleFunction(description = "Creates popup menu")

    public void Create(AndroidViewComponent component) {

        View view = component.getView(); 

        popup = new PopupMenu(context, view);

        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                    public boolean onMenuItemClick(MenuItem item) {

                        OnClick (item.getTitle().toString());

                        return true;


popup.setOnDismissListener(new PopupMenu.OnDismissListener(){
    public void onDismiss() {


    @SimpleProperty(description = "Add item in popup menu")

    public void Add(String name) {



    @SimpleFunction(description = "Show popup menu")

    public void Show() {


@SimpleFunction(description = "Show popup menu")

    public void Dismiss() {



public void Gravity(int bru){

    @SimpleEvent(description = "")

    public void OnClick (String name) {

        EventDispatcher.dispatchEvent(this, "OnClick", name);


    @SimpleEvent(description = "")

    public void Dismissed() {

        EventDispatcher.dispatchEvent(this, "Dismissed");

public int gravity()
return popup.getGravity();
1 Like

That dismiss listener code fo not work you can also compile and check

1 Like

Most of developers helping in this thread are just wasting their time,if they value the time.


What is this I do not understand what you are saying

Faraz_Firoz, how do you compile Java text into an extension? What instructions do you follow? Can I have links?

@vuk You can build/compile extension here - https://ide.niotron.com

1 Like

Hello @vuk I found these java codes from google and then I open ide.niotron.com and create an extension whose name is popup and there I add thse all java codes and click on compile extension after clicking I got popup.aix file

1 Like

Many thanks!


Great Extension !!

However, after importing the extension, there is the ADD Block missing :thinking:

Any idea why?

1 Like

are you really sure? it is just under onclick


OMG my fault..... I was searching for the green block as shown in Post 1 :relieved: :relieved:


1 Like

he updated it lol

1 Like

1. It is absolutely great.
2. Would it be possible to add BackgroundColor ?
3. Could you please add comment on hexColor it takes ?
Regards and thanks again

1 Like

Ok I will do it

You can search for hex color on google search hex color for blue you will get hex color

App Inventor uses number (integer) values as colors. So, extension developers should put integer color values as the first consideration, rather than hex colors. If you really want to convert hex colors to integer values, you have a ColorConvertHexToInt block here.

1 Like

@Faraz_Firoz, is this feature out?

No, due to some problems

Ok no problem :+1:

Hi. Thanks for this simple to use and nice extension :slightly_smiling_face:
Is it possible to change the font size of the names ?

Great little extension: but how can I remove or replace items programmatically? My app has two languages. When the user switches languages, I want to remove the items in the the list, and replace them with the new language items. At the moment, it can only ADD, so, every time the user changes languages, it adds more items to the list.

Edit: Sorry, I've just figured out that that the easiest is simply to run the .Create again.