Mein JSON-Array enthält zwei Bilder, wie man das in Aktivität anzeigt? Diese Bilder haben die Form einer URL. Nach und vor sind die Bildansichten, ich möchte wissen, was Bild-Download-Aufgabe ist und wie kann ich das verwenden.Mein JSON-Array enthält zwei Bilder, Wie man das über URL/HTTP herunterlädt und in Aktivität anzeigt
after = (ImageView) findViewById(R.id.bfrdoogret);
before = (ImageView) findViewById(R.id.afterdogret);
}
class BackGround extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = ProgressDialog.show(Serialno.this, "",
"Searching. Please wait...", true);
dialog.setCancelable(true);
dialog.show();
}
@Override
protected String doInBackground(String... params)
{
String values=getvalues();
return values;
}
@Override
protected void onPostExecute(String s)
{
dialog.hide();
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
dis.setText(district);
city.setText(cit);
serialno.setText(serial_no);
gender.setText(gende);
loction.setText(latitude+ longitude);
}
}
public String getvalues()
{
String uri = "http://www.lorryguru.com/domains/dogs/retusingsno.php?district="+District+"&serialno="+SerialNo;
HttpGet httpGet = new HttpGet(uri);
HttpClient client = new DefaultHttpClient();
HttpResponse response;
StringBuilder stringBuilder = new StringBuilder();
try {
response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
int b;
while ((b = stream.read()) != -1)
{
stringBuilder.append((char) b);
}
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
try
{
JSONArray arr = new JSONArray(stringBuilder.toString());
//result = jsonObj.getJSONArray(TAG_RESULT);
JSONObject c = arr.getJSONObject(0);
id = c.getString(TAG_ID);
district = c.getString(TAG_DISTRICT);
cit = c.getString(TAG_CITY);
serial_no = c.getString(TAG_SERIALNO);
gende = c.getString(TAG_GENDER);
wareno = c.getString(TAG_WARENO);
befor = c.getString(TAG_BEFORE);
afte = c.getString(TAG_AFTER);
latitude = c.getString(TAG_LATITUDE);
longitude = c.getString(TAG_LONGITUDE);
return "success";
}
catch (JSONException e)
{
return "accessproblem";
//e.printStackTrace();
}
tun Sie es herunterladen möchten oder es gerade von URL zeigen Imageview – Abhishek
viele offene Bibliotheken Es gibt, die Sie durch url/http, wie Universal Bild Loader, glite und Piccaso herunterladen und Anzeigebild unterstützen. – sonngaytho
_oder einfach eine andere HTTP-Anfrage zum Download-Stream und Dekodieren in Bitmap .. –