0

我正在获取“文本”表单 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

所以告诉我什么是问题?

4

0 回答 0