Android aquery图像加载,包括占位符和进度条

Android aquery图像加载,包括占位符和进度条,android,aquery,Android,Aquery,我正在尝试使用aquery进行图像加载。以下是我的布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Pro

我正在尝试使用aquery进行图像加载。以下是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ProgressBar                
        android:layout_width="60dip"       
        android:layout_height="60dip"
        android:id="@+id/progress" 
        android:layout_centerInParent="true"
        />

     <ImageView
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:id="@+id/imageViewPagerImage"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:scaleType="fitCenter" />
</RelativeLayout>
问题是,在加载图像之前会显示占位符图像,但不会显示progressbar。如果在xml布局中将progressbar放在imageview下面,如下所示:

Bitmap placeholder;
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView = mLayoutInflater.inflate(R.layout.product_detail_pager_item, container, false);

    ImageView imageView = (ImageView) itemView.findViewById(R.id.imageViewPagerImage);
    placeholder = null;
    placeholder = androidQuery.getCachedImage(R.drawable.product_detail_big);
    androidQuery.id(imageView).progress(R.id.progress).image(allUrls.get(position), false, true, 0, 0, placeholder, Constants.FADE_IN);
    imageView.setOnClickListener(listener);
    container.addView(itemView);

    return itemView;
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
     <ImageView
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:id="@+id/imageViewPagerImage"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:scaleType="fitCenter" />

     <ProgressBar                
        android:layout_width="60dip"       
        android:layout_height="60dip"
        android:id="@+id/progress" 
        android:layout_centerInParent="true" />
</RelativeLayout>
 ProgressBar progress = (ProgressBar) itemView.findViewById(R.id.progress);
androidQuery.id(imageView).progress(progress).image(allUrls.get(position), false, true, 0, 0, placeholder, Constants.FADE_IN);

这一次同时显示占位符和progressbar,但加载图像后progressbar不会消失。我想同时显示占位符和progressbar,但我想在加载图像后progressbar消失。有人能帮我吗

谢谢。

我发现了问题

似乎我必须在布局中获取对progressbar对象的引用,并按如下方式使用它:

Bitmap placeholder;
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView = mLayoutInflater.inflate(R.layout.product_detail_pager_item, container, false);

    ImageView imageView = (ImageView) itemView.findViewById(R.id.imageViewPagerImage);
    placeholder = null;
    placeholder = androidQuery.getCachedImage(R.drawable.product_detail_big);
    androidQuery.id(imageView).progress(R.id.progress).image(allUrls.get(position), false, true, 0, 0, placeholder, Constants.FADE_IN);
    imageView.setOnClickListener(listener);
    container.addView(itemView);

    return itemView;
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
     <ImageView
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:id="@+id/imageViewPagerImage"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:scaleType="fitCenter" />

     <ProgressBar                
        android:layout_width="60dip"       
        android:layout_height="60dip"
        android:id="@+id/progress" 
        android:layout_centerInParent="true" />
</RelativeLayout>
 ProgressBar progress = (ProgressBar) itemView.findViewById(R.id.progress);
androidQuery.id(imageView).progress(progress).image(allUrls.get(position), false, true, 0, 0, placeholder, Constants.FADE_IN);