Calling another method within method with the same name in Java

Jakub Folejtar

I am trying to call method which I have created long before I found out that interface I am using for another stuff need me to call its predefined method, which is the same name of the method I want to call inside. Example:

public void onClick(View v) {
    //doSomething
}
public void method() {
    Button btn = new Button(this);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //here I want to call the top onClick method
        }
    });
}

Are you guys able to help me how can I use the top method, not recursively the inside one? Thx in advance. JF

Egor

The syntax would be:

<enclosing-class>.this.onClick();

so if you're say in MainActivity, then:

MainActivity.this.onClick();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a method within the same method?

From Dev

Calling a method within another method

From Dev

Calling an object of a method of a class within another method of the same class

From Dev

Calling an object's method with the same name as another method

From Dev

An Error with Calling another Method within another method

From Java

Calling parent method from within a Thread having the same name

From Java

Calling one method from another within same class in Python

From Dev

Calling a method within the same class

From Java

Calling a Java method with no name

From Dev

Java name clash error, a method has the same erasure as another method

From Dev

Calling a method in ruby from a method with the same name

From Javascript

Calling a method from another method in the same class

From Java

Calling a method inside another method in same class

From Dev

Calling a constructor from method within the same class

From Java

OOP: Calling a public method within the same class

From Java

Calling method on another object within stream pipeline

From Java

calling another method from the main method in java

From Dev

Java Scanner Within Another Method

From Dev

Minitest - calling a mocked instance method from within another instance method

From Dev

Ruby: calling method within another method's conditional statement

From Dev

how to execute remaining code after calling another method within same controller in laravel?

From Java

Calling method of same name from different class

From Dev

Calling method of another parent of the same class

From Java

How to implement a Java method, that will call another method, based on the name of the calling class?

From Dev

Calling a synchronized method from a new thread created inside another synchronized method of the same class in Java

From Dev

How to dynamically pass name of calling method as a parameter in the same method?

From Dev

Calling a method from base class to class with same name as the method

From Dev

How to pass method name as an argument while calling another method?

From Dev

javascript why calling a method from another method in the same class need this?

Related Related

  1. 1

    Calling a method within the same method?

  2. 2

    Calling a method within another method

  3. 3

    Calling an object of a method of a class within another method of the same class

  4. 4

    Calling an object's method with the same name as another method

  5. 5

    An Error with Calling another Method within another method

  6. 6

    Calling parent method from within a Thread having the same name

  7. 7

    Calling one method from another within same class in Python

  8. 8

    Calling a method within the same class

  9. 9

    Calling a Java method with no name

  10. 10

    Java name clash error, a method has the same erasure as another method

  11. 11

    Calling a method in ruby from a method with the same name

  12. 12

    Calling a method from another method in the same class

  13. 13

    Calling a method inside another method in same class

  14. 14

    Calling a constructor from method within the same class

  15. 15

    OOP: Calling a public method within the same class

  16. 16

    Calling method on another object within stream pipeline

  17. 17

    calling another method from the main method in java

  18. 18

    Java Scanner Within Another Method

  19. 19

    Minitest - calling a mocked instance method from within another instance method

  20. 20

    Ruby: calling method within another method's conditional statement

  21. 21

    how to execute remaining code after calling another method within same controller in laravel?

  22. 22

    Calling method of same name from different class

  23. 23

    Calling method of another parent of the same class

  24. 24

    How to implement a Java method, that will call another method, based on the name of the calling class?

  25. 25

    Calling a synchronized method from a new thread created inside another synchronized method of the same class in Java

  26. 26

    How to dynamically pass name of calling method as a parameter in the same method?

  27. 27

    Calling a method from base class to class with same name as the method

  28. 28

    How to pass method name as an argument while calling another method?

  29. 29

    javascript why calling a method from another method in the same class need this?

HotTag

Archive