protected void onPostExecute(String s) {
super.onPostExecute(s);
//System.out.println("alınan data:" + s);
try{
JSONObject jsonObject = new JSONObject(s);
String poster = jsonObject.getString("Poster");
InputStream is = (InputStream) new URL(poster).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
Poster.setImageDrawable(d);
String Title = jsonObject.getString("Title");
tryText.setText("Title: " + Title);
String Year = jsonObject.getString("Year");
movieYear.setText("Year: " + Year);
}catch (Exception e){
}
}
我想显示来自JSONObject网址的图片,但是找不到方法。有一个EditText,它会在点击按钮时动态更改URL。
答案 0 :(得分:0)
你可以试试这个
Bitmap image = null;
try {
InputStream in = new URL(poster).openStream();
image = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
if(image!=null)
imageView.setImageBitmap(image);