Json图像无法加载

时间:2013-09-02 15:11:34

标签: android json

我从json获得“文本”,但我无法获得“图像”。

公共类JsonSampleActivity扩展了ListActivity {

private Context context;

// url to make request
private static String url = "http://www.bounty4u.com/android/sample_json.txt";

    //JSON Node names
 private static final String TAG_TITLE = "name";
 private static final String TAG_IMAGE = "url";

    // contacts JSONArray
    ArrayList<HashMap<String, String>> jsonlist = new ArrayList<HashMap<String, String>>();

ListView lv ;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    new ProgressTask(JsonSampleActivity.this).execute();

    }



private class ProgressTask extends AsyncTask<String, Void, Boolean> {

    private ListActivity activity;

        public ProgressTask(ListActivity activity) {
        this.activity = activity;
        context = activity;

    }

    /** progress dialog to show user that the backup is processing. */

    /** application context. */
    private Context context;

    protected void onPreExecute() {

    }

    @Override
    protected void onPostExecute(final Boolean success) {

        ListAdapter adapter = new SimpleAdapter(context, jsonlist,
                R.layout.list_item, new String[] { TAG_TITLE, TAG_IMAGE },
                new int[] { R.id.title, R.id.image1 });

        setListAdapter(adapter);


    }

    protected Boolean doInBackground(final String... args) {

        JsonParser jParser = new JsonParser();

        // getting JSON string from URL
        JSONArray json = jParser.getJSONFromUrl(url);

        for (int i = 0; i < json.length(); i++) {

            try {
                JSONObject c = json.getJSONObject(i);
               String vfuel = c.getString(TAG_TITLE);
               String vimage = c.getString(TAG_IMAGE);

                HashMap<String, String> map = new HashMap<String, String>();


                map.put(TAG_TITLE, vfuel);
                map.put(TAG_IMAGE,vimage);

                jsonlist.add(map);
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        return null;
    }


}

我收到错误:resolveUri在错误的位图uri上失败:http://www.bounty4u.com/android/images/angie.jpg

告诉我什么是问题?

0 个答案:

没有答案