java无法将imageview传递到Glide
我试图从我的ImageView动物园上的Glide加载图像
但它不会在我的imageView上显示图像
我的图像视图ID是动物园
从url从JSON对象加载图像
在上显示错误::--
Glide.with(this).load(url).into(menagerie);
以下是全文 代码:--
public void loadMore() {
String url = "http://my-json-feed";
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.get,
url, null, new
Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
String url = null;
try {
url = response.getString("url");
} catch (JSONException e) {
e.printStackTrack();
}
Glide.with(this).load(url).into(menagerie);
}
}
}
# 1 楼答案
改为使用getApplicationContext(),如下图所示。使用(getApplicationContext())。加载(imageUrl)。进入(图像视图)
# 2 楼答案
您在
with.(this)
处出错用
getApplicationContext()
代替this
您在^{处出错
你不应该通过身份证
您需要初始化一个变量并向其传递一个id
像这样>
那么你应该这样做>