gpt4 book ai didi

java - Picasso加载图片报错-Android

转载 作者:行者123 更新时间:2023-11-29 05:12:12 26 4
gpt4 key购买 nike

主 Activity .java

class LoadProfile extends AsyncTask<String, String, String>{

protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EventHome.this);
pDialog.setMessage("Loading...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}

/**
* getting Profile JSON
* */
protected String doInBackground(String... args) {
// Building Parameters
String json = null;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(PROFILE_URL);
httppost.setEntity(new UrlEncodedFormEntity(params));

// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
json = EntityUtils.toString(resEntity);

Log.i("All Events: ", json.toString());
} catch (Exception e) {
e.printStackTrace();
}

return json;
}

@Override
protected void onPostExecute(String json) {
super.onPostExecute(json);
// dismiss the dialog after getting all products
pDialog.dismiss();
try{
event_all = new JSONObject(json);
JSONArray user = event_all.getJSONArray("events");
JSONObject jb= user.getJSONObject(0);
String name = jb.getString("name");
String venue=jb.getString("location");
String date=jb.getString("date_d");
String descr=jb.getString("descr");
image1=jb.getString("images1");

// displaying all data in textview

tv3.setText(name);
tv4.setText(venue+", "+date);
tv5.setText(descr);
Picasso.with(this).load(image1).into(iv7);
}catch(Exception e)
{
e.printStackTrace();
}

}

}

在执行上面的代码时,我在行 Picasso.with(this).load(image1).into(iv7);

上遇到了一些错误

错误是Picasso 类型中带有(context) 的方法不适用于参数(MainActivity.LoadProfile)

我的编码有什么问题。

最佳答案

你可以改变

Picasso.with(this).load(image1).into(iv7);

Picasso.with(MainActivity.this).load(image1).into(iv7);

试一试。

关于java - Picasso加载图片报错-Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28038898/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com