I'm not sure why this might be considered the "hard way"... Can you
elaborate on why it is not easy for you?

In answer to your question; I believe getRootView() would also do what you want:

http://developer.android.com/reference/android/view/View.html#getRootView()


Regards,

Sean

On 5/31/09, westmeadboy <[email protected]> wrote:
>
> I have one main.xml layout (top level is a LinearLayout) resource and
> I inflate this in the usual way within Activity.onCreate():
>
> setContentView(R.layout.main);
>
> Now, I want to get a reference to the corresponding LinearLayout, but
> how?
>
> At the moment I have to add an id attribute to the LinearLayout
> defined in the resouce file and then do this:
>
> LinearLayout mainLayout = (LinearLayout)findViewById(R.id.mainLayout);
>
> But I'm sure there must be an easier way?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to