>From the javadoc:
" * @return The root View of the inflated hierarchy. If root was supplied,
* this is the root View; otherwise it is the root of the inflated
* XML file."
So in your case, parent is returned.
On Wed, Sep 30, 2009 at 1:13 PM, Jason Proctor
<[email protected]> wrote:
>
> something weird is happening when i inflate a particular view and i
> wonder whether i'm running into some kind of namespace collision
> inside the resource/class space.
>
> i have a few custom views in my app and generally i park them in
> discrete XML files. the views are declared --
>
> // myview.xml
> <?xml version="blah.... ?>
>
> <com.mydomain.MyView
> xmlns=...
> >
> <!-- subview stuff in here -->
> <LinearLayout....>
> </com.mydomain.MyView>
>
> i then cast the return of inflate() appropriately in code --
>
> MyView view = (MyView) inflater.inflate (R.layout.myview, parent, true);
>
> -- and then the class itself usually extends LinearLayout
>
> // MyView.java
>
> public class MyView
> extends LinearLayout
> {
> // ...
> }
>
> this generally works fine. the views are pretty much implemented
> identically. however, with one of these views i'm seeing that the
> type coming back is LinearLayout rather than MyView. eh? i changed
> the name of the view to something ridiculous and confirmed that the
> inflater would blow up on an unfound class. so i know it's looking at
> the class name -- but not instantiating the class (the constructor
> never gets called).
>
> i dumped out some stuff about the LinearLayout that is coming back
> from the inflater and from the child count etc seems like the *first
> child* of the custom view.
>
> under what circumstances would the inflater bring back the child of
> the specified view and not the view itself? weird that it only
> happens with some views.
>
> thanks in advance
>
> --
> jason.vp.engineering.particle
>
> >
>
--
Romain Guy
Android framework engineer
[email protected]
Note: please don't send private questions to me, as I don't have time
to provide private support. 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
-~----------~----~----~----~------~----~------~--~---