I'm not sure how 'hiding' the member vars in something like AdapterView makes it easier to maintain the platform. AdapterView just extends ViewGroup, so it would be straight forward for me to implement a copy of AdapterView just by extending ViewGroup, and then i could whack away at anything i wanted to. It seems to me that hiding the member vars in something like AdapterView doesn't give many advantages and just makes it harder to reuse existing code. Well anyhow, that's how it looks from over here.. :)
On Nov 30, 9:52 pm, Dianne Hackborn <[email protected]> wrote: > Member variables are implementation details. Exposing them for applications > to whack away on them as they want would make it much more difficult to > maintain the platform. > > > > > > On Mon, Nov 30, 2009 at 1:41 PM, Taf <[email protected]> wrote: > > OK a better example would be: > > > boolean mInLayout = false; > > > in AdapterView, this has no get or set function so it can only be > > accessed by classes in the same package such as Gallery with it's > > onLayout function: > > > protected void onLayout(boolean changed, int l, int t, int r, int > > b) { > > super.onLayout(changed, l, t, r, b); > > > /* > > * Remember that we are in layout to prevent more layout > > request from > > * being generated. > > */ > > mInLayout = true; > > layout(0, false); > > mInLayout = false; > > } > > > I want to create a similar class to Gallery, but because my classes > > are not in the same package i cannot access mInLayout. even though I > > extend AbsSpinner and hence AdapterView, > > > so should mInLayout be protected? If it was i could then access it > > and write a similar custom class to Gallery.. > > > On Nov 30, 9:01 pm, Taf <[email protected]> wrote: > > > Hi, > > > > I was just trying to extend the AbsSpinner Class, to create my own > > > custom widget. But the problem is that some of the member variables > > > have a a default scope, so I can't access them just by extending the > > > class (they can only be access directly by classes in the same > > > package). Some are ok as they have getters and setters , but there is > > > the odd member variable that doesn't , so i simply can't access them > > > because my new custom widget in not in the same package. An example of > > > such a member variable is mSelectedPosition in AdapterView. > > > > Would it not be better if these vars were to have a protected scope > > > rather than the default scope, it would then be easier to extend these > > > classes to make custom widgets outside of the package of these > > > classes. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%2Bunsubs > > [email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

