I am new to Android dev. I have read several books about this. And all authors strongly recommend using anonymous classes instead of overriding the class.
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 someone explain to me why?
Ofc, if I use the override class for many different objects, this will be a problem for modification.
But if I use my own class only for a specific object, then the logic of my class will not change much, can I use it? Or should I use an anonymous class?
source share