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,
View<http://developer.android.com/reference/android/view/View.html>convertView,
ViewGroup<http://developer.android.com/reference/android/view/ViewGroup.html>parent
)
{
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 [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