- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 Glide 将自定义图像加载到 Google map 信息窗口。我将 Activity 上下文传递给适配器(请参阅下面的代码)。但我既没有看到图像也没有看到错误。
我做错了什么?
class GuideMapInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
private final View mWindow;
private final View mContents;
private HashMap<Marker, MapPoint> mMarkers;
private Context mContext;
GuideMapInfoWindowAdapter(Context context, HashMap<Marker, MapPoint> markerMapPointHashMap) {
mWindow = getLayoutInflater().inflate(R.layout.guide_map_custom_info_window, null);
mContents = getLayoutInflater().inflate(R.layout.guide_map_custom_info_content, null);
mMarkers = markerMapPointHashMap;
mContext = context;
}
@Override
public View getInfoWindow(Marker marker) {
render(marker, mWindow);
return mWindow;
}
@Override
public View getInfoContents(Marker marker) {
render(marker, mContents);
return mContents;
}
private void render(Marker marker, View view) {
ImageView mImage = (ImageView) view.findViewById(R.id.badge);
MapPoint mPoint = markers.get(marker);
String mUrl = UrlBuilder.guidePhoto(mPoint.getGuideId(), mPoint.getPageId(), 100);
Glide.with(mContext)
.load(mUrl)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(mImage);
String title = marker.getTitle();
TextView titleUi = ((TextView) view.findViewById(R.id.title));
if (title != null) {
titleUi.setText(title);
} else {
titleUi.setText("");
}
String snippet = marker.getSnippet();
TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
if (snippet != null) {
snippetUi.setText(snippet);
} else {
snippetUi.setText("");
}
}
}
最佳答案
问题是,您正在异步下载图像。在 getInfoContents
中返回 mContents
后,对 imageview 的任何更改都不会反射(reflect)出来。
我已经更新了你的渲染函数,不过还没有测试过。
private void render(Marker marker, View view) {
ImageView mImage = (ImageView) view.findViewById(R.id.badge);
MapPoint mPoint = markers.get(marker);
String mUrl = UrlBuilder.guidePhoto(mPoint.getGuideId(), mPoint.getPageId(), 100);
Bitmap image = Glide.with(mContext)
.load(mUrl)
.asBitmap()
.into(-1,-1)
.get();
mImage.setImageBitmap(image);
String title = marker.getTitle();
TextView titleUi = ((TextView) view.findViewById(R.id.title));
if (title != null) {
titleUi.setText(title);
} else {
titleUi.setText("");
}
String snippet = marker.getSnippet();
TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
if (snippet != null) {
snippetUi.setText(snippet);
} else {
snippetUi.setText("");
}
}
关于android - 将 Glide 与 GoogleMap.InfoWindowAdapter 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33605911/
从 Gilde 3.7.0 迁移到 Glide 4.9.0。 如下定义我的 MyAppGlideModule。 @GlideModule public class MyAppGlideModule
我将 Glide JS 用于我使用 ACF 和 Gutenberg Blocks 构建的幻灯片。 但是下一个按钮有问题。 ">"无法正确呈现 - 它会破坏整个 DOM。 “data-glide-dir
我到处搜索,但因为 Glide 已经发布了 4.4 版。我再也找不到应用 RoundedCornersTransformation 的方法了。我正在使用 glide-transformations甚至
我想调整 gif 文件的大小并保存它。我尝试使用一些建议的方法,但这些方法会出错,后来我才知道 Glide v4 中不推荐使用某些方法 byte[] bytes = Glide.
我正在尝试使用 firebase 在 android studio 中开发一个消息应用程序。根本没有语法错误。但是当我使用实现 'com.github.bumptech.glide:glide:4.8
这是我的代码: d.setBounds(15, 8, d.getIntrinsicWidth(), d.getIntrinsicHeight()); ImageSpan span = new Imag
我很难从 firebase 存储中获取图像 URL,我从数据库中获取了照片 URL,但据我所知,Glide 无法从这样的链接获取图片:com.google.firebase .storage.Uplo
我使用 Glide我的应用程序中的库内部自定义适配器 View 。但我有错误: "You must not call setTag() on a view Glide is targeting" 我的
我试图添加编译 应用程式 bulid.gradle compile 'com.github.bumptech.glide:glide:3.7.0' 当我尝试运行该应用程序时,它给了我错误 NoCla
我尝试了所有可能的方法,但无法弄清楚如何在我的 json 更新时更新图像以滑动 我的 android 应用程序最初使用 glide 从 json 加载图像,之后它只从缓存加载图像。它不会加载在服务器上
首先我集成了 Room 数据库并将一些信息存储到 db,其中包含一些图像 URL,现在我需要在 ImageViews 中显示这些图像。 现在尝试使用 glide,添加依赖项和注释处理器, 实现'com
我的房车有问题。我正在将 mp3 的封面艺术加载到字节数组中,然后使用 glide 将字节数组加载到图像中 (vh.coverArt)。但是,当我使用 glide 而不是仅使用 .SetImageBa
简单的 Glide.with(context).load(url).into(image) 在将项目与 同步后无法正常工作 compile 'com.github.bumptech.glide:gli
我真的为 Rails 的所有新 JS 更改而苦苦挣扎。我正在尝试实现非常简单的 slider 脚本 Glide.js 这是我的 app/javascripts/packs/front.js 文件: /
Build.gradle(模块:App) apply plugin: 'com.android.application' android { compileSdkVersion 23
我正在创建一个应用程序,让用户通过按 ImageView 来更改他/她的图像,该图像将来自他/她的图库并将上传到我的 FirebaseStorage 中。用户的个人详细信息单独上传到 Firebase
我可以通过滑动将图像成功加载到 ImageView 中,并使用 .circularCrop() 方法对其进行裁剪。 Glide.with(this) .load("https://i.img
使用 glide 在 recyclerview imageview 项目上加载图像。受阻 Glide 听众我意识到图像资源已准备好,但图像未显示在 imageview 中。当我在 Glide 监听器
我在我的应用程序中使用 glide 加载图像。它在我的情况下工作正常,比如 if(image_enabled==1){ Glide.with(getContext()).load(constant.S
是否可以使用 缓存图像? Glide 未在 imageView 中显示?.如果是那怎么办? 现在我正在做这个代码: Glide .with(getApplicationContext()) .
我是一名优秀的程序员,十分优秀!