>
> First of all, thank you for your replies.
>

Sure thing, always willing to help.
 

> The data source is simply a data structure in memory whose size can vary 
> but for
> testing purposes it is not very large. I am now looking at your solution as 
> well, but
> am really curious as to why the code I have posted is not working. I am 
> afraid I
> might run into the same issue with your code as the one I have at the  
> moment,
> that is, when I call setText(), is the text going to update?
>

When you keep a reference to a view as an object and you pass that object to 
a ListView, if you update the view, it automatically updates on the 
ListView.

I've used this to do lazy loading of images and names from the contact 
manager in the phone.
 

> I like to keep my UI code separate from my data. I pass my data around and
> reflect changes in the data in my UI separately. That way, even if I need 
> to
> rewrite an app for say the BlackBerry or something, I only need to change
> the UI code.
>

If you like to keep your data in a seperate object, you can just add one of 
those objects in your view.

public class DataItem extends LinearLayout
{
     private YourDataObject myObject;

     // Previous provided code.
}

I know this still combines them, but you can just drop out the DataItem by 
deleting the class and your done.  The code bases would still be seperate.

Here is my issue, maybe someone can help, if I give two calls of the 
> following type:
>
> evView1 = (EditView )findViewById( R.id.evView);
> evView2 = (EditView )findViewById( R.id.evView);
>
> do evView1 and evView2 point to the same object or are they separate 
> instances?
>

Yes, they point to the same object.

Using the method I gave reduces the need to constantly recreate view since 
you can just repopulate them. The only drawback is you will start using a 
lot of memory if you have a ton of them hanging around. You can always 
release the current array and rebuild once you get too many extra. This also 
makes it where you control when the GC kicks in, making a better experience 
for your user.

If you are going to have the data living in memory, there is no good reason 
to use something other than a view to hold them as you aren't adding that 
much memory usage.  If you are going to drop the data in a database or 
something like that, then I would use another approach, but it would still 
use the LinearLayout object, it just wouldn't keep it around in memory.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to