大家好,我对进度条有问题。我试着做一个画廊视图,所有的图像都显示在网格视图中。但问题是,当所有的图像都被加载时,进度条并没有消失,请检查我使用旋转加载作为进度条的代码
已更新
public class ImageAdapter extends BaseAdapter {
private Context mContext;
ProgressDialog progressDialog;
RotateLoading rotateLoading;
int count;
public ImageAdapter(Context c) {
mContext = c;}
public int getCount() {
return mThumbIds.length;
}
@Override
public String getItem(int position) {
return mThumbIds[position];
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
convertView= LayoutInflater.from(mContext).inflate(R.layout.image_gallery,parent,false);
imageView=(ImageView)convertView.findViewById(R.id.imageView2);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(380,480));
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
// rotateLoading=(RotateLoading)convertView.findViewById(R.id.rotateloading);
progressDialog=ProgressDialog.show(mContext,"Loading Data","Please wait.....",false,false);
} else {
imageView = (ImageView) convertView.findViewById(R.id.imageView2);
}
String url = null;
url=getItem(position);
Glide.with(mContext)
.load(url)
.thumbnail(0.5f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(android.R.drawable.progress_indeterminate_horizontal)
.centerCrop()
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
// rotateLoading.setVisibility(View.INVISIBLE);
// rotateLoading.stop();
progressDialog.dismiss();
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
//rotateLoading.setVisibility(View.INVISIBLE);
//rotateLoading.stop();
progressDialog.dismiss();
return false;
}
})
.crossFade()
.into(imageView);
return convertView;
}
// Keep all Images in array
public String[] mThumbIds = {
"http://idealphotography.biz/wp-content/uploads/2016/06/Wide-wallpaper-nature-480x800-In-Wallpaper-HD-1366x768-with-wallpaper-nature-480x800-Download-HD-Wallpaper.jpg",
"http://greenywallpapers.com/wallpapers/10/275050-nature-wallpapers-720x1280.jpg",
"https://idealphotography.biz/wp-content/uploads/2016/06/Best-wallpaper-nature-480x800-For-Wallpapers-Image-with-wallpaper-nature-480x800-Download-HD-Wallpaper.jpg",
"https://idealphotography.biz/wp-content/uploads/2016/06/Best-wallpaper-nature-480x800-In-Windows-Wallpaper-Themes-with-wallpaper-nature-480x800-Download-HD-Wallpaper.jpg",
"https://idealphotography.biz/wp-content/uploads/2016/06/Highres-wallpaper-nature-480x800-About-Windows-7-Wallpaper-with-wallpaper-nature-480x800-Download-HD-Wallpaper.jpg",
"http://freewallpaper-background.com/wp-content/uploads/2014/11/M-3.jpg",
"http://naturewallpaperfree.com/mobile/sky/nature-wallpaper-480x800-127-96fbd452.jpg",
};
}
这是xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="380dp"
android:layout_height="380dp"
android:id="@+id/imageView2"
/>
<com.victor.loading.rotate.RotateLoading
android:id="@+id/rotateloading"
android:layout_width="80dp"
android:layout_height="80dp"
app:loading_width="5dp"
android:visibility="visible"
app:loading_color="#ffffff"
android:layout_centerInParent="true"/>
</RelativeLayout>
[![Check the image][1]][1]
in the image the picture loads but the progress bar did not stops and invisible.
请解决这个问题。
[1]: http://i.stack.imgur.com/2Vqyp.jpg
我创建了一个库,它显示了Imageview的进度:PowerfulImageView。
导入,添加到gradle此行
compile 'com.stefanosiano:powerlessimageview:0.3.1'
然后用以下内容更改xml:
<com.stefanosiano.powerfulimageview.PowerfulImageView
android:layout_width="380dp"
android:layout_height="380dp"
android:id="@+id/imageView2"
app:piv_progress_mode="circular" />
然后将getView方法更改为:
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
PowerfulImageView imageView;
if (convertView == null) {
convertView= LayoutInflater.from(mContext).inflate(R.layout.image_gallery,parent,false);
imageView=(PowerfulImageView)convertView.findViewById(R.id.imageView2);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(380,480));
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
} else {
imageView = (PowerfulImageView) convertView.findViewById(R.id.imageView2);
}
imageView.changeProgressMode(PivProgressMode.CIRCULAR);
String url = null;
url=getItem(position);
Glide.with(mContext)
.load(url)
.thumbnail(0.5f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(android.R.drawable.progress_indeterminate_horizontal)
.centerCrop()
.crossFade()
.into(imageView);
return convertView;
}
如果一切正常,请告诉我:)
更新xml文件
<com.victor.loading.rotate.RotateLoading
android:id="@+id/rotateloading"
android:layout_width="80dp"
android:layout_height="80dp"
app:loading_width="5dp"
app:loading_color="#ffffff"
android:layout_centerInParent="true"
android:visibility="invisible"/>
在getView()方法中,
rotateLoading.start();
rotateLoading.setVisibility(View.VISIBLE);
Glide.with(mContext)
.load(url)
.thumbnail(0.5f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.fitCenter()
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
rotateLoading.setVisibility(View.INVISIBLE);
rotateLoading.stop();
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
rotateLoading.setVisibility(View.INVISIBLE);
rotateLoading.stop();
return false;
}
})
.crossFade()
.into(imageView);
嗨,我想有一个图像的进度条,将显示图像加载时,但当图像加载将完成,我想把它设置为去。早些时候我用毕加索图书馆来做这个。但我不知道如何在Glide库中使用它。我知道有一些资源就绪的功能,但我不知道如何使用它。有人能帮我吗? 毕加索图书馆代码 现在我该如何使用Glide? 我能够加载图像,这与Glide,但我怎么能写在代码中的某个地方,如果图像被加载?
我见过很多关于如何分别设置ImageView和GridView的高度和宽度的问题。这里,这里,还有这里 但是,我想知道如何设置两者。 这是我的设置。在我的GridView中,我有一个ImageView和一个TextView。我有一些不同宽度和大小的图像,我想调整它们的大小,使其始终是屏幕正方形大小的1/3。下面,我有一段文字描述。 这是我到目前为止的代码。。。 gallerygridview.xm
尝试使用自定义变量设置的可见性,但发生错误:。是否可以使用数据绑定设置视图可见性?多谢了。
我有一个布局,即MotionLayout,它必须为我定义了motionscene约束集开始和结束的FrameLayouts。并且它们是正确的动画。 然后,在这个动画框架布局下,我添加了两个文本视图,在单击时,我尝试隐藏一个,显示另一个,但两个都保持可见 重写有趣的onViewCreated(View:View,SavedInstanceState:Bundle?){super.onviewcrea
我想显示 3x3 大小的网格视图。我想根据设备大小设置高度和宽度。我从这个链接中获取参考。 主要活动- 活动_主要- 编辑- 就像首先得到屏幕高度和宽度,然后每个项目的高度和宽度是我得到的屏幕高度和宽度值的1/3。