1

In my project i am using google webService in which i am quering different query like-- hospital, cinema hall, resort etc. and get result in json format . From json i get so many data like Name, lat, lng, imageUrl, Web url in respective query. And i am manupulating these data and showing it in my Expandable listView. I am able to do show all data but when i am loading image on ImageView it is showing some mismatch. For loading image, I am using ImageLoader, FileCache, MemoryCache and Utils java class. Basically question is i have http web url for image and now i want to show it on my ImageView at Expandable listView, and i am not properly perform it. Please any buddy help.

Teekam
  • 939
  • 4
  • 14
  • 26
  • 3
    Post some code, then only some one can understand what mistake you are doing – TNR Nov 02 '12 at 06:53
  • From question, i can say you are using Lazy List code for loading image asynchronously. I am not sure what problem you are facing but here you can find tutorial/example: [Android – Asynchronous image loading in ListView](http://www.technotalkative.com/android-asynchronous-image-loading-in-listview/) – Paresh Mayani Nov 02 '12 at 06:54
  • when are you getting image from url is not directlly add in imageview.just convert in byte array – ckpatel Nov 02 '12 at 06:55
  • 1
    as @Nagaraj436 said you should post some code.. – Kailash Dabhi Nov 02 '12 at 07:17

2 Answers2

0

Actually you have not posted any code so it is difficult to tell you the exact problem, but this link will help you, here i am fetching data into listview using json, use as you need

I want to let user add multiple items by action sequence

Some Code:-

JSONArray jsonArray = json.getJSONArray(KEY_CATEGORY);

for(int i=0;i < jsonArray.length();i++){                        
    HashMap<String, String> map = new HashMap<String, String>();
    JSONObject jsonObject = jsonArray.getJSONObject(i);                     

    map.put("id",  String.valueOf(i));
    map.put(KEY_TITLE, jsonObject.getString(KEY_TITLE));
    map.put(KEY_DESCRIPTION, jsonObject.getString(KEY_DESCRIPTION));
    map.put(KEY_COST, jsonObject.getString(KEY_COST));
    map.put(KEY_THUMB_URL, jsonObject.getString(KEY_THUMB_URL));
    itemsList.add(map);
} 
Community
  • 1
  • 1
  • As i have two list in Expandable list like Taxi Company and Hospital, and each have 10 record each, which is shown in layout with help of expandablelistviewAdapter, each is showing image (whose record have image url, in case not having imageUrl i am placing default image). when i view one list record it show me correct result for image, after i view another list record it also show correct resul, but when i come again first list result it shows some results of second list in case of image loading. – Teekam Nov 02 '12 at 09:55
  • are you using imageloader or lazyadapter in your project – Stanley Fox Nov 02 '12 at 10:23
  • @IGP , fine, still i am waiting for your reply, possible or not to make that one, at least clear the pic – Stanley Fox Nov 02 '12 at 10:41
  • @IGP how to update View Cart form every time whenever user click on Add to Cart Button. – Stanley Fox Nov 02 '12 at 10:52
  • @IGP I want to let user add multiple items by action sequence like: select item --> enter quantity and add item to cart --> back to listview --> select item --> enter quantity and add item to cart --> finally user will be able to view all the previously added item(s) into ViewCart Form, you just need to make that one.. – Stanley Fox Nov 02 '12 at 10:56
  • @IGP i already told you, i believe on you, it means yes, i know you will make viewcart activity for me in my given code – Stanley Fox Nov 02 '12 at 11:03
0

Tikam done, try to use this class,

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;



    /**
     * 
     * @author JSR
     *
     */

 public class StreamUtils {

/**
 * A helper method to convert an InputStream into a String
 * @param inputStream
 * @return the String or a blank string if the IS was null
 * @throws IOException
 */
public static String convertToString(InputStream inputStream) throws IOException {
    if (inputStream != null) {
        Writer writer = new StringWriter();

        char[] buffer = new char[1024];
        try {
            Reader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 1024);
            int n;
            while ((n = reader.read(buffer)) != -1) {
                writer.write(buffer, 0, n);
            }
        } finally {
            inputStream.close();
        }
        return writer.toString();
    } else {
        return "";
    }
}
 }