私は何日もこの解決策を得ようとしていますが、まだ運がありません. 親切に助けてください。URL をパラメーターとして受け取り、ImageView に返す関数を作成する必要があります。このコードを変更してそれを行う方法を誰かが親切に教えてくれますか? 下に赤い線が表示されますimgURL.setImageBitmap(directory.getString(TAG_IMAGE));
public class ViewProfileActivity extends Activity {
ImageView imgURL;
TextView txtName;
String eid;
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
private static final String url_veiw_directory = "http://website.com/app/include/view_directory.php";
private static final String TAG_SUCCESS = "success";
private static final String TAG_DIRECTORY = "directory";
private static final String TAG_ID = "eid";
private static final String TAG_IMAGE = "image";
private static final String TAG_NAME = "name";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_directory);
Intent i = getIntent();
eid = i.getStringExtra(TAG_ID);
new GetDirectoryDetails().execute();
}
class GetDirectoryDetails extends AsyncTask<String, String, String> {
protected String doInBackground(String... params) {
runOnUiThread(new Runnable() {
public void run() {
int success;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", eid));
JSONObject json = jsonParser.makeHttpRequest(url_veiw_directory, "GET", params);
Log.d("Single Directory Details", json.toString());
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
JSONArray directoryObj = json.getJSONArray(TAG_DIRECTORY);
JSONObject directory = directoryObj.getJSONObject(0);
imgURL = (ImageView) findViewById(R.id.image);
txtName = (TextView) findViewById(R.id.name);
imgURL.setImageBitmap(directory.getString(TAG_IMAGE));
txtName.setText(directory.getString(TAG_NAME));
}else{
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
}