我遇到加载问题" Glide"图像进入" ImageView"使用" viewPager"。
当我尝试使用" drawable"资源它工作正常但由于某种原因(我猜因为它是异步)它不等待Glide更新视图。只有3个屏幕的空白viewPager没有崩溃。
另外," Firebase"安装工作正常。
我知道很难用这么多的lib和东西复制一个问题,但是如果你能在评论部分提出一些建议那就太棒了
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 :(得分:0)
问题是缺少ImageView片段的默认图像。目前所有工作都按预期进行。
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@android:drawable/screen_background_dark" />