我正在尝试从 api(tmdb) 获取电影列表图像 但我不知道是我使用的api错误还是GLIDE
这是 Glide 的一段代码:
` override fun onBindViewHolder(holder: MovieViewHolder, position: Int) {
holder.binding.apply {
val movie = movies[position]
val imageBase = "https://image.tmdb.org/t/p/w500/"
Glide.with(holder.itemView)
.load(imageBase + moviePoster)
.error(R.mipmap.tvmovieposter)
.centerCrop()
.into(holder.binding.moviePoster)
movie
movieTitle.text = movies[position].title
MovieReleaseDate.text = movies[position].release_date
}
}
these are the errors in run:`your text`
/Glide: Load failed for https://image.tmdb.org/t/p/w500/androidx.appcompat.widget.AppCompatImageView{995e7ba V.ED....I. 0,0- 0,0 #7f080119 app:id/movie_poster} with size [300x400] `your text``
I/Glide: Root cause (1 of 1)
com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:98)
您的图片网址可能不正确。
您可以调试并查看
moviePoster
的值到底是什么吗
更新:只需添加一条日志消息即可查看
imageBase + moviePoster
的值