0

I have been trying several ways of displaying my json images but my solutions never succeded.

I have parsed my json and I'm getting the response.

However included the respose is an image which I need to display in my app.

Recieving the image as :"http: //media.rightmove.co.uk/31k/30471/29462938/30471_FLE100159_IMG_00_0002_max_200x1‌​38.jpg" which is just string.I have these below images in my database.

How can I display these image in my app?

![Parsed images][1]

Thanks in advance

below code.

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");
    }
}

Many thanks

SomCollection
  • 481
  • 1
  • 7
  • 17
  • possible duplicate of [how to load an imageview by url in android?](http://stackoverflow.com/questions/2471935/how-to-load-an-imageview-by-url-in-android) – Marek Sebera Feb 19 '12 at 15:43

2 Answers2

0

Try that my friend :) Parse your json and take the URL and then put them us URL in the method https://asantoso.wordpress.com/2008/03/07/download-and-view-image-from-the-web/

vlad_o
  • 587
  • 6
  • 17
  • Thanks,similar but not what I wanted.Just need to display these json string as images as soon as I recieve their responses. – SomCollection Feb 19 '12 at 20:55
0

The jSON doesn't actually contain the images, it contains links to the image. If you feed those URLs into a WebView or Browser, you will see the images.

try this:

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

this will draw the image into the webview. You can define your webview in xml or programatically as I did above.

edthethird
  • 6,263
  • 2
  • 24
  • 34
  • Yes correct can you tell me more,i've figure that out but i'm really stacked with displaying these string as images.How can i display these images as soon as I recieve the json response? – SomCollection Feb 19 '12 at 20:58
  • there are a couple ways, I will edit my response to show an easy one – edthethird Feb 20 '12 at 17:21
  • ,Many thanks for your response,I have posted my progress so far I would be grateful if you could spare a minute and tell me where i'm going wrong. – SomCollection Feb 21 '12 at 17:10