I don't understand this:
OnGlobalLayoutListener listener = new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
System.out.println("I am override a method");
}
public void hello(){
System.out.println("This is a new method");
}
};
//listener.hello(); Why I cannot do it?
Without this I can do it:
new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
System.out.println("I am override a method");
}
public void hello(){
System.out.println("This is a new method");
}
}.hello();
Why in the first case cannot I invoke the method hello() and the second case I can do it?