Take the 2-minute tour ×

I'm making use of a List<? extends Map<String,?>> that I populated with data.

while (cursor.getPosition() < cursor.getCount()) {
    item.put("ProdSize", cursor.getString(3));

    list.add(i, item);
    item = new HashMap<String,String>();    
    i = i + 1;

How do I update a value for example in the OrdQty field?

share|improve this question
You mean like list[3].put("OrdQty","7")? You haven't told us how to modify an item, so I'm guessing. –  Beta Sep 25 '11 at 21:19
it wont let me use the put command :( –  shawrie Sep 25 '11 at 21:22
It's because it's a list and not an array. It should be list.get(3).put("ordQty","7"). BUT don't do that... –  KarlP Sep 25 '11 at 21:32
I am stucked i the same situation..what is the type of item here. –  Shajeel Afzal Sep 7 '13 at 7:58
add comment

2 Answers

up vote 2 down vote accepted

@Duffymo is right, you shouldn't use a map as a pseudo-object.

This is how to update an object at a specific place (index) in a list.

Map<String,?> ugly = list.get(index);

Then you can do whatever you want with the object ugly.

If you did it properly, it would look like this...

Product p = list.get(index);
share|improve this answer
add comment

Looks like a very bad design to me. Java's an object-oriented language. Why don't you provide a real contract and create Product and Order objects? Give Order a List of Products to maintain. What you're proposing is less self-explanatory and harder to write and maintain.

share|improve this answer
im having to use this method to populate a listview while giving me the option to overide the getView method –  shawrie Sep 25 '11 at 21:24
I don't see how a better design using real objects conflicts with that goal. Everything you wrote was about "view", which is separate from the object model. –  duffymo Sep 25 '11 at 21:26
add comment

Your Answer


