I read in some book that using inner class will make the app bigger(several KBs per inner class used), but is there any concern about the performance? I saw inner classes used in Google’s sample code, but in general, is it encouraged to use inner class or not, in Android?
Thanks!
1. Inner classes are excellent when you want to implement an interface method more than 1 time and in more than 1 way in the same class.
2. Anonymous classes are the best way to create event handlers.
3. Using top level classes (ie static inner class) will be light, as it moreover like an external class which is not having any implicit reference to the outer class.
4. Non-static inner class will be bit of overhead, as it holds implicit reference to the outer class.
Eg:
For inner class having implict reference
Eg: