android - Kotlin:将 URL 转换为位图时的毕加索问题
问题描述
在这段代码中有“java.lang.IllegalStateException:方法调用不应该从主线程发生。” 问题
如何解决这个问题
user_URL[i] 值为(URL:字符串)
代码是:
user_URL = maprepo.returnImage()
latitude = maprepo.returnLatitude()
longitude = maprepo.returnLongitude()
for (i in 0 until latitude.size step (1)) {
var bitmap: Bitmap =Picasso.with(context).load(user_URL[i]).get()
val makerOptions = MarkerOptions()
makerOptions
.position(LatLng(latitude[i], longitude[i]))
.title("")
.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
googleMap.addMarker(makerOptions)
}
解决方案
推荐阅读
- vue.js - 如何修复 TNS 医生错误
- android - 如果用户注销应用程序,他们还能收到推送通知吗?
- asp.net - 出站 Web.Config URL 重写
- python - 将项目附加到不带 [ ] 括号的列表
- pycharm - 无效的语法.. 缺少 [] - 但没有?
- javascript - 何时使用 Uint8Array、Uint16Array、Uint32Array
- r - 检索每个值的数据范围并对它们进行排序
- linkedin - LinkedIn v2 API:如何将 ugcPost-URN 转换为共享 URN?
- python - 调用 Flash restful 服务时在烧瓶上显示错误。TypeError:“响应”类型的对象不是 JSON 可序列化的
- jsf - 如何在 JSF 中创建对象实例