Inflate the view from your xml, you can do something like this:

LayoutInflater inflator =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
myView = inflator.inflate(R.layout.my_view, null);

Then you can use myView.findViewById(), and add whatever you want to
your View. Finally, call setContentView(myView).

Hope it helps!

Luis.

On 24 mayo, 08:38, Santosh Salunke <[email protected]>
wrote:
> Hi,
>
> I am creating a layout through code and want to add a View to that
> layout. The view which is to be added is defined in the xml file.
> Is there any way to use an View from xml before calling setContentView
> method. Because we can not call findViewById before setContentView.
>
> Any pointers on this would be helpful :)
>
> Regards,
> Santosh Salunke
>
> --
> 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 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
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

Reply via email to