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. Http chunked response and Connection Reset by Peer error

Hi everyone,

I'm facing an annoying problem here.
My application is connected to a server that sends some data from time
to time. It's some kind of eventing server. In order to receive data,
I'm connecting to the server with an HttpURLConnection, retrieve the
response InputStream and loop on it with the read method. The
connection is always open.

The distant server is cutting the connection every 5 minutes (for test
purpose). When connection is closed, my application has to reconnect
again. We detect a Connection Reset by Peer exception when the server
closes the connection. The problem is that most of the time, I never
receive the Connection Reset by Peer exception. So my application
can't know that is has to reconnect and it's stucked on the read
instruction.

The InputStream.Read() method shouldn't always raise an exception if
the connection is closed?
What can I do to always detect Connection Reset by Peer exception?

Thanks for any help,

Android 2.1
HTC Desire

Cdric

-- 

2. Delete SMS

Hi All,

I am writing my own SMS application that will display a toast of my
message once it arrive. Now is it possible to delete the message after
the display of the toast, so that it will not go into the native SMS
application?

Thanks In Advance,
Perumal

-- 

3. Funny Computer Trick - Shaking Windows

4. loading classes.dex

5. Android multiple heading list view

6. How to catch the picture and sound

7. Acer Aspire Distros?