Question: I am able to setup a listview using custom adapter which shows correct output.each list item also has an gradient style see drawable.xml below how do I change the item background to some other gradient on tapping any of them. can I set different gradients for each of the items.? 

```
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
<gradient 
android:startColor="#FFFAFAFA" 
android:centerColor="#FFFFFFFF" 
android:endColor="#FFFAFAFA" 
android:angle="90"/>
</shape>

```

My files...

activity\_main.xml....Main xml file

MainActivity.java....Main activity

Item.java.... item selector method

ItemAdaptor.... custom adapter

list\_item.xml..... item (textView) styling

Answer: 
The nice thing about iterator is that later on if you wanted to switch your vector to a another STD container. Then the forloop will still work.
its a matter of speed. using the iterator accesses the elements faster. a similar question was answered here:

[What's faster, iterating an STL vector with vector::iterator or with at()?](https://stackoverflow.com/questions/776624/whats-faster-iterating-an-stl-vector-with-vectoriterator-or-with-at)

Edit:
speed of access varies with each cpu and compiler