I'm attempting to override an Android View class to tweak the functionality just slightly. But I need to modify a field that does not have a setter method. I've placed the subclass in a package called android.widget
. Why can't I access any of the package-private member fields? I notice that the compiler says they "cannot be resolved," rather than not being accessible. Does this have something to do with how Android.jar is built?
views:
35answers:
2
+2
A:
Those methods are not part of the Android SDK and so therefore are unavailable to you directly from an SDK application. If you are building firmware, you can access them directly. Presumably, your subclass could get at them via reflection, though bear in mind that such fields (or any other non-SDK stuff) is subject to change in any given Android release.
CommonsWare
2010-10-07 23:02:26
+2
A:
It's also a side effect of class loaders. Your android.widget package is not the same android.widget package used by the system.
Romain Guy
2010-10-07 23:17:22