Wednesday, August 3, 2011

Re: [android-developers] Re: instantiating widgets from an xml layout within a custom View class leads to nullpointerexception

03.08.2011 23:34, CresCoJeff пишет:
> Okay, I included the @Override onFinishInflate and put the code
> addressing the anotherB Button object inside it... the NPE no longer
> occurs, but the code inside onFinishInflate is also never executed, so
> I'm not sure this fixed anything.

Well, something did change, since you're no longer getting the NPE.

> What exactly does "Even if the
> subclass overrides onFinishInflate, they should always be sure to call
> the super method, so that we get called" mean?

Android documentation comes from JavaDoc comments in the code.

I assume that's the reason for the "we" - as in "we, the code inside
Android".

> Should onFinishInflate
> be called like so: super.onFinishInflate(); and if that is the case,
> where should it be called?

It's called by Android to let the view know that its children have been
inflated and added - so you can call this.findViewById().

--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment