ImageView's invalidate not working
<p>I have created the page indicator for the viewpager.In which i am changing the indicator image when user swipe in viewpager.</p>

<p>Below is my code for onPageSelected#ViewPager.OnPageChangeListener</p>

<pre><code>public void onPageSelected(int position) {
    int childCount = this.layout.getChildCount();
    for (int i = 0; i &lt; childCount; i++) {
        PageItem child = (PageItem) this.layout.getChildAt(position);
        if (i == position) {
            child.setActiveState();
        } else {
            child.resetState();
        }
    }
    this.layout.invalidate();
}
</code></pre>

<p>Below is my PageItem class</p>

<pre><code>public class PageItem extends ImageView {

private int activeBitmap;
private int inActiveBitmap;
private boolean isActive;

public PageItem(Context context, AttributeSet attrs, int defStyle,
        int activeBitmapId, int inActiveBitmapId) {
    super(context, attrs, defStyle);
    this.activeBitmap = activeBitmapId;
    this.inActiveBitmap = inActiveBitmapId;
    this.setImageResource(inActiveBitmap);
    isActive = false;
}

public PageItem(Context context, AttributeSet attrs, int activeBitmapId,
        int inActiveBitmapId) {
    super(context, attrs);
    this.activeBitmap = activeBitmapId;
    this.inActiveBitmap = inActiveBitmapId;
    this.setImageResource(inActiveBitmap);
    isActive = false;
}

public PageItem(Context context, int activeBitmapId, int inActiveBitmapId) {
    super(context);
    this.activeBitmap = activeBitmapId;
    this.inActiveBitmap = inActiveBitmapId;
    this.setImageResource(inActiveBitmap);
    isActive = false;
}

public void resetState() {
    this.setImageDrawable(this.getContext().getResources()
            .getDrawable(inActiveBitmap));
    this.invalidate();
    isActive = false;
}

public void setActiveState() {
    this.setImageDrawable(this.getContext().getResources()
            .getDrawable(activeBitmap));
    this.invalidate();
    isActive = true;
}
</code></pre>

<p>}</p>

<p>Now after starting my application when i do swipe first time it change the image but then after it does not change the image.</p>

<p>thanks in advance.</p>
