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

It would be good if you included this information in the first post :slight_smile:

Sure why not wait

1 Like

@Patryk_F how was this extension

well done @Faraz_Firoz this Popup extension is easy to use and works well

1 Like

Thank you @potocnik

Good work @Faraz_Firoz!

One suggestion, can you add a 'when Popup1. Dismiss' event in the next version?

1 Like

Ofcose I also think same I add in my next version

1 Like

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;

@DesignerComponent(

        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){

        super(container.$form());

        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(){
@Override
    public void onDismiss() {
      Dismissed();
    }
});

    }

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

    public void Add(String name) {

        popup.getMenu().add(name);

    }

    @SimpleFunction(description = "Show popup menu")

    public void Show() {

        popup.show();

    }
@SimpleFunction(description = "Show popup menu")

    public void Dismiss() {

        popup.dismiss();

    }

@SimpleProperty
public void Gravity(int bru){
popup.setGravity(bru);
}

    @SimpleEvent(description = "")

    public void OnClick (String name) {

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

    }

    @SimpleEvent(description = "")

    public void Dismissed() {

        EventDispatcher.dispatchEvent(this, "Dismissed");

    }
@SimpleProperty
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.

4 Likes

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!

2 Likes

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

2 Likes

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

Screenshot_2

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