Hızlı yanıt: kod örneği
The common term or these inline class definitions is Anonymous Classes.You can read more about the discussion on these in Java/Android: anonymous local classes vs named classesEssentially the main differences are readbility, speed of coding, re-use and scope.From a resource point of view the anonymous class creation may cause an overhead in the garbage collector as discussed in Avoid Creating Unnecessary Objects. I am not certain on the exact details of anonymous class creation, however, it is logical that implementing the interface on the class is more efficient.@WilliamTMallard has provided an example of what NOT to do. In his example, a long and syntacticly complex handler should be implementented on the class rather than anonymous handler because it is harder to read and edit when defined inline.