How to move the position of Progress bar when the image loads in List View
<p>I am loading the images one by one in Listview by running the task in back ground.I am running a progress bar until it loads fully.The position of progress is not changing when the image starts loading.I want the postion of the progressbar also to be changed when the images loads.How to do it? what am i doing wrong?</p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relaGrid"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;include
        android:id="@+id/Master"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        layout="@layout/activity_master_page" /&gt;

    &lt;ListView
        android:id="@+id/ItemView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/Master" &gt;
    &lt;/ListView&gt;

&lt;ProgressBar
        android:id="@+id/ItemsProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Master"
        android:layout_centerHorizontal="true" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>Added the code for loading image</p>

<p>private class testAynscTask extends AsyncTask {</p>

<pre><code>    @Override
    protected void onPreExecute() {
        TheProgressBarG = (ProgressBar) findViewById(R.id.ItemsProgressBar);
        TheProgressBarG.setVisibility(View.VISIBLE);
    }

    protected Void doInBackground(Void... ParamsP) {

        try {
            POSManager aPOSManagerL = new POSManager();
            ListCriteria aListCriteriaL = new ListCriteria();
            ObjectInformation zItemInfoL = new ObjectInformation();
            CategoryItemListG = new ObjectList();
            //Get CategoryId
            String zCategoryIdL = GetCategoryId();

            aListCriteriaL.SearchConditionsM.AddSearchConditionWithValue("Item_Category.Id", zCategoryIdL);
            Gson gsonBuilderL = new GsonBuilder().serializeNulls().create();
            String zListCriteriaL = gsonBuilderL.toJson(aListCriteriaL);

            //Get Category Items List
            aPOSManagerL.GetCategoryItems(HttpUtil.SessionKeyM,zListCriteriaL);

            DisplayMetrics zDisplayMetricsL = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(zDisplayMetricsL);
            int nPreviewSizeL = zDisplayMetricsL.widthPixels / 3;

            ObjectList zItemListL = HttpUtil.CategoryItemListM;

            for (int countL = 0; countL &lt; zItemListL.GetLength(); countL++) {

                zItemInfoL = (ObjectInformation) zItemListL.GetObject(countL);
                String zItemIdL = (String) zItemInfoL.GetValue("ID");
                //Get Item Image
                aPOSManagerL.GetCategoryItemImage(HttpUtil.SessionKeyM,zItemIdL, nPreviewSizeL);
                zItemInfoL.SetValue("aPictureByteArrayP",HttpUtil.CategoryItemImageBytesM);
                CategoryItemListG.Add(zItemInfoL);
                publishProgress(countL);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    protected void onProgressUpdate(Integer... PositionP) {

        ListView TheItemListViewL=(ListView) findViewById(R.id.ItemView);
        TheItemListViewL.setAdapter(anImageAdapterG);
        super.onProgressUpdate(PositionP);
    }

    @Override
    protected void onPostExecute(Void ResultP) {
        super.onPostExecute(ResultP);
        TheProgressBarG.setVisibility(View.INVISIBLE);
        anImageAdapterG.notifyDataSetChanged();

    }
}
</code></pre>

<p>public class ImageAdapter extends BaseAdapter {
        private Context mContextL;</p>

<pre><code>    public ImageAdapter(Context contextP) {
        mContextL = contextP;
    }

    public int getCount() {
        return CategoryItemListG.GetLength();
        // return mImageIds.length;
    }

    public Object getItem(int PositionP) {
        return PositionP;
    }

    public long getItemId(int PositionP) {
        return PositionP;
    }

    public View getView(int PositionP, View ConvertViewP, ViewGroup ParentP) {

        ObjectInformation zItemInfoL = (ObjectInformation)CategoryItemListG.GetObject(PositionP);
        String zItemNameL = (String)zItemInfoL.GetValue("ITEMNAME");
        String zItemPriceL = (String)zItemInfoL.GetValue("SalesPrice");
        String zItemImageBytesL = (String)zItemInfoL.GetValue("aPictureByteArrayP");

        Bitmap ItemImageBitMapL =GetItemImageBitMap(zItemImageBytesL);

         RelativeLayout TheRelativelayoutL = new RelativeLayout(getApplicationContext());

         ImageView TheItemImageL = new ImageView(mContextL);
         TheItemImageL.setImageBitmap(ItemImageBitMapL);
         TheItemImageL.setScaleType(ImageView.ScaleType.FIT_XY);
         TheItemImageL.setLayoutParams(new ListView.LayoutParams(100,100));
         TheItemImageL.setPadding(1, 0, 0, 0);
         TheItemImageL.setId(1);

         TextView tvItemNameL = new TextView(mContextL);
         tvItemNameL.setText(zItemNameL);
         tvItemNameL.setGravity(Gravity.CENTER);
         tvItemNameL.setTextSize(10);
         tvItemNameL.setTextColor(Color.parseColor("#000000"));
         tvItemNameL.setPadding(15, 0, 0, 0);
         tvItemNameL.setId(2);

         TextView tvItemPriceL = new TextView(mContextL);
         tvItemPriceL.setText("Rs. "+zItemPriceL);
         tvItemPriceL.setGravity(Gravity.CENTER);
         tvItemPriceL.setTextSize(10);
         tvItemPriceL.setTextColor(Color.parseColor("#A30000"));
         tvItemPriceL.setId(3);
         tvItemPriceL.setPadding(15, 0, 0, 20);

         TheRelativelayoutL.addView(TheItemImageL);

         RelativeLayout.LayoutParams zRelativeLayoutParamsL = new RelativeLayout.LayoutParams((RelativeLayout.LayoutParams.WRAP_CONTENT),(RelativeLayout.LayoutParams.WRAP_CONTENT));
         zRelativeLayoutParamsL.addRule(RelativeLayout.RIGHT_OF,1);
         zRelativeLayoutParamsL.addRule(RelativeLayout.CENTER_IN_PARENT);

         TheRelativelayoutL.addView(tvItemNameL, zRelativeLayoutParamsL);

         zRelativeLayoutParamsL = new RelativeLayout.LayoutParams((RelativeLayout.LayoutParams.WRAP_CONTENT),(RelativeLayout.LayoutParams.WRAP_CONTENT));
         zRelativeLayoutParamsL.addRule(RelativeLayout.RIGHT_OF,1);
         zRelativeLayoutParamsL.addRule(RelativeLayout.BELOW,2);
         zRelativeLayoutParamsL.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

         TheRelativelayoutL.addView(tvItemPriceL, zRelativeLayoutParamsL);

         return TheRelativelayoutL;
    }
</code></pre>
