I use Application to access my data.
And while buttom be click, I want to use the data which in Application.
I use below code:
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MyData md = (MyData)this.getApplication();
md.setName("");
md.setIP("");
}
});
But the error show:
The method getApplication() is undefined for the type new View.OnClickListener(){}
How to use getApplication in onClick method?
By getApplication(), I assume you are referring to Activity.getApplication().
In this case, if you remove the
thisit should work.