2012-02-19 75 views
0

我一直在尝试多种方式来显示我的json图像,但我的解决方案从未成功。如何显示此json图像

我已经解析了我的json,并且得到了响应。

但是,包含respose是一个图像,我需要在我的应用程序中显示。

收到图像为:“http://media.rightmove.co.uk/31k/30471/29462938/30471_FLE100159_IMG_00_0002_max_200x1 38.jpg”这只是string.I在我的数据库中有下面这些图像。

如何在我的应用程序中显示这些图像?

![解析的图像] [1]

预先感谢

下面的代码。

protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

    JSONParser prop = new JSONParser(); 
    JSONObject json = prop.getJSONFromUrl(url); 
    try{ 
    properties = json.getJSONArray(TAG_PROPERTY); 
    for (int i = 0; i < properties.length(); i++) { 
     JSONObject c = properties.getJSONObject(i); 
     String photoThumbnailUrl = c.getString(TAG_PHOTOS);    

    // load image view control 
    imgView = (ImageView) findViewById(R.id.imgView); 

    // grab image to display 
    try { 
     imgView.setImageDrawable(grabImageFromUrl(photoThumbnailUrl)); 


    } catch (Exception e) { 
     txtUrl.setText("Error: image not grabed"); 
    } 
    } 
    }catch (Exception ex) { 
    txtUrl.setText("Error: Properties not recieved"); 
    } 
} 

非常感谢

+0

可能重复[如何在Android中通过url加载imageview?](http://stackoverflow.com/questions/2471935/how-to-load-an-imageview-by-url-in-android) – 2012-02-19 15:43:36

回答

0

的JSON实际上并不包含图像,它包含图像的链接。如果您将这些URL提供给WebView或浏览器,您将看到图像。

试试这个:

String x = <URL of image, pulled out of JSON object> 
Webview wv = new WebView(this); 
wv.loadURL(x); 

这将绘制的图像到web视图。你可以像上面那样用xml或编程方式定义你的webview。

+0

是的,你可以告诉我更多,我已经弄清楚了,但是我真的把这些字符串显示为图像。如何在我收到json响应后立即显示这些图像? – SomCollection 2012-02-19 20:58:45

+0

有几个方法,我会编辑我的回复,以显示一个简单的答案 – edthethird 2012-02-20 17:21:42

+0

,非常感谢您的回复,我已经发布了我的进度,如果您可以腾出一分钟并告诉我我要去哪里,我将不胜感激错误。 – SomCollection 2012-02-21 17:10:55