2016-11-27 75 views
0

我有用「viewPager」將「滑動」圖像加載到「ImageView」的問題。viewPager不顯示滑動圖像

當我嘗試使用「drawable」資源時,它工作正常,但出於某種原因(我猜是因爲它是異步的),它不會等待Glide更新視圖。沒有什麼崩潰只有3屏幕空白viewPager。

P.S此外,「Firebase」設置工作正常。

我知道,這是非常難以複製的一個問題,這麼多庫之類的東西,但如果你可以在註釋部分拋出一些建議,這將是巨大

import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ImageView; 

import com.bumptech.glide.Glide; 
import com.firebase.ui.storage.images.FirebaseImageLoader; 
import com.google.firebase.storage.FirebaseStorage; 
import com.google.firebase.storage.StorageReference; 

public class ScreenSlidePageFragment extends Fragment { 
    public static final String ARG_OBJECT = "object"; 

    // Firebase Initial code. 
    private FirebaseStorage storage = FirebaseStorage.getInstance(); 
    private StorageReference storageRef = storage.getReferenceFromUrl("gs://myfirebase_example"); 
    private StorageReference fileRef = storageRef.child("images/3.jpg"); 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    ViewGroup rootView = (ViewGroup) inflater.inflate(
      R.layout.fragment_screen_slide_page, container, false); 

    Bundle args = getArguments(); 

    //TODO: Find out how to load the images with Glide, now it is not waiting. 
    ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView); 
    //setImageResource(args.getInt(ARG_OBJECT)); 

    // Getting one image from the DB, it is working perfectly. 
    Glide.with(getActivity()) 
      .using(new FirebaseImageLoader()) 
      .load(fileRef) 
      .into(imageView); 

    return rootView; 
} 
} 

回答

0

的問題是缺少的默認圖像爲ImageView片段。目前所有工作都按預期工作。

<ImageView 
    android:id="@+id/imageView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:srcCompat="@android:drawable/screen_background_dark" />