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: 
It always depends on what you need.

You should use `operator[]` when you **need** direct access to elements in the vector (when you need to index a specific element in the vector). There is nothing wrong in using it over iterators. However, you must decide for yourself which (`operator[]` or iterators) suits best your needs.

Using iterators would enable you to switch to other container types without much change in your code. In other words, using iterators would make your code more generic, and does not depend on a particular type of container.
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.