[android-developers] Re: dynamic listview problem: would like EditText change to trigger another EditText change

2011-09-28 Thread Studio LFP
Have you considered just making your custom objects views?

You can make the object extend a LinearLayout and place a EditText in it and 
have your view and data structure all as one object.

Then you can just keep an array of these objects and when one changes, just 
iterator over them and change them all.

I do something like...

public class CustomItem extends LinearLayout
{
private EditView evView;

// Additional data fields here.

public void createView( LayoutInflater inflater )
{
inflater.inflate( R.layout.item, this, true );

evView = (EditView )findViewById( R.id.evView);
}

public void populate()
{
 // Populate data here.
}
}

Just create the array of object, populate them, create their internal view 
and return the objects via index in an ArrayAdapter to a ListView.

CustomItem[] ciList = new CustomItem[ x ];

Use a for loop or whatever processing loop you use to get the data and in 
each:

ciList[x] = new CustomItem();
ciList[x].populate();
ciList[x].createView( inflater );  // I do an LayoutInflater.from( context ) 
and reuse it.

Then in the ArrayAdapter:

public int getCount() { return ciList.length; }
public View getView( int position, 
Viewhttp://developer.android.com/reference/android/view/View.htmlconvertView, 
ViewGrouphttp://developer.android.com/reference/android/view/ViewGroup.htmlparent
 )
{
 return ciList[ position ];
}

Now when you get a press/long press or any other action in a callback, type 
the returned view to your class and all the data is right there for you to 
use.

Steven
Studio LFP
http://www.studio-lfp.com

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

Re: [android-developers] Re: dynamic listview problem: would like EditText change to trigger another EditText change

2011-09-28 Thread TreKing
On Wed, Sep 28, 2011 at 12:17 PM, Studio LFP studio@gmail.com wrote:

 Just create the array of object, populate them, create their internal view
 and return the objects via index in an ArrayAdapter to a ListView.


This of course throws out the recycling optimization ListVIew does, so may
not be practical for large data sets.

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

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

Re: [android-developers] Re: dynamic listview problem: would like EditText change to trigger another EditText change

2011-09-28 Thread Studio LFP
On Wednesday, September 28, 2011 12:49:15 PM UTC-5, TreKing wrote:

 On Wed, Sep 28, 2011 at 12:17 PM, Studio LFP studi...@gmail.com wrote:

 Just create the array of object, populate them, create their internal view 
 and return the objects via index in an ArrayAdapter to a ListView.


 This of course throws out the recycling optimization ListVIew does, so may 
 not be practical for large data 
 sets.http://sites.google.com/site/rezmobileapps/treking


You can easily get around this by using an ArrayList that can be added to or 
removed from as needed and adding lazy loading to the object to get the data 
and populate the view when it is asked to show itself.

Based on what he is trying to do, he's still holding all the data anyway.  
Putting it in a view object instead of just a regular object doesn't add 
that much memory, but makes the application a ton faster and a lot easier to 
write.  Those alone make it worth it.

Steven
Studio LFP
http://www.studio-lfp.com

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

[android-developers] Re: dynamic listview problem: would like EditText change to trigger another EditText change

2011-09-28 Thread Studio LFP
Mr. Goche,

How much data and what is the source of the data you are using to create the 
EditText views?

Knowing the data load and its source would help a lot.

Steven
Studio LFP
http://www.studio-lfp.com

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