I'm new in Android dev. I read some books about it. And all authors strongly recommend to use anonymous classes instead of class redefinition.
They say that
TextView txtTitle;
...
txtTitle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
better than
txtTitle.setOnClickListener(new MyOnClickListener(position));
...
private class MyOnClickListener implements OnClickListener{
...
}
Can anybody explain me why?
Ofc, if I will use redefinition class for many different object this will be the problem for modification.
But if I use my own class only for specific object, so logic of my class will not strongly change, can I use it? Or should I use anonymous class?