Skip to content Skip to sidebar Skip to footer

Android Activity As Inner Class

I'm trying to declare an Android Activity as an inner class. This Activity should only be spawned by the containing class and needs access to some of its private methods (Methods I

Solution 1:

An instance of the inner class has a reference to the containing instance of the containing class. You can create an instance of the inner class only from a method (or constructor) of the containing class.

Probably you can make the inner class static. It will be able to access the parent class fields only if you provide an explicit reference, but I think you can live with that.

You should also consider creating a special package and using package visibility.

Post a Comment for "Android Activity As Inner Class"