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
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.
Comments