依赖库,从官网的首页是找到了如下:
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.github.bumptech.glide:okhttp-integration:c1.5.0@aar'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
链接1:https://github.com/bumptech/glide/wiki/Integration-Libraries
链接2:https://github.com/bumptech/glide
然后简单的调用方法:
Glide.with(mContext)
.load(imageUrl)
.into((ImageView) viewHolder.getView(R.id.img));
然后报这样子的错误:
08-27 10:23:55.494 14650-14650 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.xxxx.yyyy, PID: 14650
java.lang.AbstractMethodError: abstract method not implemented
at com.bumptech.glide.integration.okhttp.OkHttpGlideModule.registerComponents(OkHttpGlideModule.java)
at com.bumptech.glide.Glide.initializeGlide(Glide.java:230)
at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:171)
at com.bumptech.glide.Glide.get(Glide.java:155)
at com.bumptech.glide.Glide.getRetriever(Glide.java:528)
at com.bumptech.glide.Glide.with(Glide.java:554)
at com.aaaa.bbbb.ui.recylerview.MultipleRecyclerAdapter.convert(MultipleRecyclerAdapter.java:78)
at com.aaaa.bbbb.ui.recylerview.MultipleRecyclerAdapter.convert(MultipleRecyclerAdapter.java:22)
at com.chad.library.adapter.base.BaseQuickAdapter.onBindViewHolder(BaseQuickAdapter.java:937)
at com.chad.library.adapter.base.BaseQuickAdapter.onBindViewHolder(BaseQuickAdapter.java:68)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6356)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6389)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5335)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5598)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:636)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1167)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:852)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:871)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
at android.view.View.layout(View.java:14981)
at android.view.ViewGroup.layout(ViewGroup.java:4790)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.ja
abstract method not implemented
太乌龙了~,看Document4.0的链接:http://bumptech.github.io/glide/int/okhttp3.html
解决方法唉,以后还是需要非常仔细的看一下文档才行,人家在https://github.com/bumptech/glide/wiki/Integration-Libraries的首页已经写得很清楚了,这只合适于v3版本,v4版本请看http://bumptech.github.io/glide/。
网友评论