我有一个适用于viewPgaer的适配器,我在ImageView上使用UIL缓存图像。我在加载图像时从未使用过ProgressBar,它工作得很好。我决定制作和进度条,但是当我打开活动时,进度条正在旋转,过了一会儿它就像它应该的那样消失但图像没有显示,此外我无法滑动到下一个图像。我不知道我做错了什么。谢谢:))
ViewPager适配器
@Override
public Object instantiateItem(ViewGroup container, int position) {
TouchImageView imgDisplay;
inflater = (LayoutInflater) _activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container,
false);
imgDisplay = (TouchImageView) viewLayout.findViewById(R.id.imgDisplay);
final ProgressBar spinner = (ProgressBar) viewLayout.findViewById(R.id.progressBarFull);
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(_activity.getApplicationContext()).build();
ImageLoader.getInstance().init(config);
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(_imagePaths.get(position), imgDisplay, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
spinner.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
spinner.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
spinner.setVisibility(View.GONE);
}
});
((ViewPager) container).addView(viewLayout);
return viewLayout;
}
layout_fullscreen_image.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">
<com.plushost.wizgr.TouchImageView
android:id="@+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:background="#000000"/>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarFull"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="gone"/>
</RelativeLayout>
微调器消失后的活动屏幕截图