unable to add imageviews in linearlayout dynamically
<p>I have a problem that I am generating ImageViews dynamically and adding those in Linearlayout. But the problem is that first time it works nicely means added all image views in LinearLayout but when we run the same code second time the it adds only one image. I don't know why? Please suggest me the solution regarding the same.</p>

<p><strong>Code:</strong></p>

<pre><code>protected void callAfterEff() {
        layout_Pagination.removeAllViews();
        img_Pagination = new ImageView[Overview_Years.size()];
        paramsPagination = new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        //params.weight = 0.5f;

        paramsPagination.gravity= Gravity.CENTER_VERTICAL;
        paramsPagination.setMargins(10, 2, 0, 0);
        // TODO Auto-generated method stub
        for(int i=0;i&lt;overviewYears.getYears().size();i++)
        {
            img_Pagination[i] = new ImageView(Overview.this);
            img_Pagination[i].setLayoutParams(paramsPagination);
            /*if(count==i)
            {
                img_Pagination[count].setBackgroundResource(R.drawable.pagination_selected);
            }
            else
            {*/
                img_Pagination[i].setBackgroundResource(R.drawable.pagination_unselected);
        //}
            layout_Pagination.addView(img_Pagination[i]);
        }
    }
</code></pre>
