comparison between viewstub and latoutinflater to add view at runtime?

by Hitendrasinh Gohil » Thu, 19 May 2011 21:55:52 GMT


Sponsored Links
 hi,

What is the difference between using viewstub and layoutinflater to
inflate views at runtime?

-- 



Re: comparison between viewstub and latoutinflater to add view at runtime?

by Diego Tori » Thu, 19 May 2011 22:41:18 GMT


 If I recall correctly, ViewStub acts as a lazy XML include, in that the 
referenced view only gets added to the view hierarchy in the time that it's 
inflated, not ahead of time. The gain on this method is that it makes it 
quick and cheap to inflate a view, however, once it's inflated, it cannot be 
recreated or re-inflated (since the VS reference is gone from the 
heirarchy). LayoutInflater on the other hand allows you to inflate views at 
will, and add them directly into the heirarchy, however, you have to deal 
with the overhead of inflating them.

-- 


Sponsored Links


Re: Re: comparison between viewstub and latoutinflater to add view at runtime?

by Dianne Hackborn » Fri, 20 May 2011 00:13:16 GMT


 I'm not sure it makes sense to compare them.  ViewStub is a view that uses
LayoutInflater to inflate its view hierarchy when needed.  As far as
inflating the view hierarchy goes, they are the same.  They just are
different APIs, so the only interesting different between them is really the
obvious difference in how you use the API.

On Thu, May 19, 2011 at 7:41 AM, Diego Tori






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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.

-- 



Other Threads

1. Access inbuilt Contacts functionality of phone in my application.

Hi all,

I want to access the inbuilt Contacts functionality in my application.
If it is possible, than how? Anybody have any idea regarding this way?

I really need you help. I would appreciate your help.

Thanks.

-- 

2. iAsk: Cafe World on Nexus?

Prends,


Buat para pemakai Nexus One yg juga suka maen game fesbuk.
Mau nanya dong, game Cafe World jalan ngga sih?
Soale kalo jalan, bakalan ada temen yg terkapar berbusa-busa nih.
Kalo Mafia Wars mah udah bisa dari jaman G1.

Tolong sharenya yah. 

TIA,

Iwan

-- 
--------------------
"Indonesian Android Community [id-android]" 

Join,  visit the following page:

3. .... .. | .- -. -.. .-. --- .. -.. . .-. ... -.-.-- | .... --- .-- | .- .-. . | -.-- --- ..- | - --- -.. .- -.-- ..--..

4. N1 Tips

5. Two onCreate (and onDestroy) invocations on orientation chage

6. OOT: Miring Kelapa Gading

7. ShaHow to make android emulator support larger screen