I’m having a problem designing some code to handle dynamic, two-dimensional data in my Android applicaton. I’ve tried solving this using an ArrayAdapter, but there’s a problem:
As far as I can tell, there’s no way to remove data from an ArrayAdapter by its position (or index). Using an ArrayAdapter, you have to remove by value like this:
arrayAdapter.remove (stringValue1);
This is fine for half my data because the first value in the pair (the “x-value”) is guaranteed to be unique (among the x’es), but this isn’t reliably true for the second value. I’ve tried some stupid gymnastics to make the “y-value” unique, but that’s not proving to be a very good idea.
Can anyone recommend an Android data type (or Java, I guess) that will be both dynamically re-sizeable and will allow me to remove precisely the data I need to??
Thanks,
R.
An ArrayList of String objects, sounds like it would do the job, and it’s dynamically resizable as well:
http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html
Remove by index:
Check if it contains a certain object by object comparison: