2016-10-14 12 views
0

こんにちはみんなが私の問題を解決してくれます。私はプログレスバーのrotateprogressバーを使っていましたが、画像が読み込まれてもそれは目に見えませんでした。私もデフォルトのプログレスバーを試しますが、結果は同じです。 ここに私のコードです。カスタムビューは、作品をRotateLoading方法画像がグライドで読み込まれたときにRotateProgressバーがグリッドビューで停止しませんでした

public class ImageAdapter extends BaseAdapter { 
private Context mContext; 
//ProgressDialog progressDialog; 

String activity; 
RotateLoading rotateLoading; 
int count; 
// Constructor 
public ImageAdapter(Context c,String v) { 
    mContext = c; 
    activity=v; 
} 

public ImageAdapter(Context c) { 
    mContext = c;} 

public int getCount() { 

    return mThumbIds.length; 

} 

@Override 
public Object getItem(int position) { 
    return null; 
} 

public String getItemThumb1(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) { 

    final 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.rotateloading1); 




    } else { 
     imageView = (ImageView) convertView.findViewById(R.id.imageView2); 


    } 
    String url; 
    url=getItemThumb1(position); 



    rotateLoading.start(); 

    Glide.with(mContext) 
      .load(url) 
      .thumbnail(0.5f) 
      .diskCacheStrategy(DiskCacheStrategy.ALL) 
      // .placeholder(R.drawable.loadingimage) 
      .centerCrop() 
      .crossFade() 
      .listener(new RequestListener<String, GlideDrawable>() { 
       @Override 
       public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { 
        rotateLoading.start(); 
        imageView.setVisibility(View.GONE); 
        return false; 
       } 

       @Override 
       public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { 

        rotateLoading.stop(); 
        imageView.setVisibility(View.VISIBLE); 
        return false; 
       } 
      }) 
      .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="match_parent" 
    android:layout_height="match_parent" 
    android:scaleType="centerCrop" 
    android:id="@+id/imageView2" 
    android:visibility="invisible" 
    /> 

<com.victor.loading.rotate.RotateLoading 
    android:id="@+id/rotateloading1" 
    android:layout_width="80dp" 
    android:layout_height="80dp" 
    app:loading_width="5dp" 
    android:visibility="visible" 
    app:loading_color="#ffffff" 
    android:layout_centerInParent="true"/> 
</RelativeLayout> 
+0

後にこれを追加した後、視認性がなくなって作ってみることができますか?それ以外の場合、imageViewを再び膨張させるのはなぜですか? – shivamDev

答えて

0

私はさっぱりだが。したがって、rotateLoading.stop()を呼び出すと、ビューが非表示になったり、表示されなくなります。だから、rotateLoading.stop()

がGridLayoutManagerでRecyclerViewを使用していないのはなぜrotateLoading.stop();

rotateLoading.setVisibility(View.GONE); 
+0

rotateloading.stop()はプログレスバーを非表示にします。 – Dani

+0

私がprogressbar.setvisibility(View.Gone)を呼び出すときに、デフォルトのプログレスバーを使用するとプログレスバーも非表示にならない – Dani

+0

グライドコールバック – shivamDev

関連する問題