Error in my code

I want to get clicked popup menu item but I fail
What I try

popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

    @SimpleEvent(description = "")

    public void OnClick(String name) {

        Item(name.getTitle());

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

    }

    }
1 Like

@Faraz_Firoz do one thing make @SimpleEvent Out of curly brackets and then when ever there is click then call them using event block :slightly_smiling_face:

And in Hindi
@SimpleEvent alag bnao
Fir jab bhi click ho us event ko call karo

:grin:

:wink:

That’s not possible if you know then tell me I try once

Wait @Faraz_Firoz let me share

1 Like

Share as fast as you can

What happen @iAditya-Nanda send me the code

It must be :

popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

   @Override
 public void OnClick() {

        PopupClicked();

    }

    }
@SimpleEvent()
public void PopupClicked(){
EventDispatcher.dispatchEvent(this, "clicked");
}
1 Like

Is there any import for @Override

No import needed for override,
:upside_down_face:

1 Like

Thankyou
@Moderator please mark @LGdeveloper post as solution

1 Like

Thankyou @LGdeveloper aka @know about it aka Rudra

1 Like

Code compiled ?
:upside_down_face:

@Faraz_Firoz

Here

@SimpleEvent
 public void OnClick(String name){
EventDispatcher.dispatchEvent(this, "Item", name);

Event Code​:point_up_2:

popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){ 
public boolean onMenuItemClick(MenuItem item) { 
OnClick(item.getTitle()) ;
return true; 
} });

Wrong code, on click event will never be triggered

@LGdeveloper Same code used but this

Started Compiling Project Popup
Buildfile: /compiler/android/build.xml

javac:
[mkdir] Created dir: /compiler/android/build/UQYwJ/classes
[javac] Compiling 1 source file to /compiler/android/build/UQYwJ/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /compiler/android/src/UQYwJ/com/faraz/popup/Popup.java:58: error: expected
[javac] popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
[javac] ^
[javac] /compiler/android/src/UQYwJ/com/faraz/popup/Popup.java:58: error: illegal start of type
[javac] popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
[javac] ^
[javac] /compiler/android/src/UQYwJ/com/faraz/popup/Popup.java:58: error: ')' expected
[javac] popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
[javac] ^
[javac] /compiler/android/src/UQYwJ/com/faraz/popup/Popup.java:58: error: ';' expected
[javac] popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
[javac] ^
[javac] /compiler/android/src/UQYwJ/com/faraz/popup/Popup.java:58: error: invalid method declaration; return type required
[javac] popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
[javac] ^
[javac] /compiler/android/src/UQYwJ/com/faraz/popup/Popup.java:60: error: ';' expected
[javac] public void OnClick() {
[javac] ^
[javac] 6 errors
[javac] 1 warning