我一直在尝试几种显示 JSON 图像的方法,但我的解决方案从未成功。
我已经解析了我的 JSON 并得到了响应。
然而,包括响应是我需要在我的应用程序中显示的图像。
将图像接收为:“img src=question/images/u2_1_l2_q66”,这只是字符串。我得到的文本与模拟器"not a image"中的文本相同。
在drawable中,我应该添加图像吗?
如何在我的应用程序中显示这些图像?请指导我。
任何帮助都是不言而喻的。
代码
       protected String doInBackground(String... args) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("tid", tid));
        json = jsonParser.makeHttpRequest(url_get_quesurl, "GET", params);
        Log.d("All Groups: ", json.toString());
        try {
        int success = json.getInt(TAG_SUCCESS);
        if (success == 1) {
            System.out.println("Success");
            groups = json.getJSONArray(TAG_GROUP);
            System.out.println("Result Success+++"+groups);
             for (int i = 0; i < groups.length();i++) {
            JSONObject c = groups.getJSONObject(i);
            String question = c.getString(TAG_QUES);
            System.out.println("Checking ::"+question);
            ques1.add(question);
            String img = c.getString(TAG_IMAGE);
            System.out.println("Checking ::"+img);
            imgarr.add(img);
             }
        } else {
            showAlert();
        }
    } catch (JSONException e) {
        System.out.println("Error "+e.toString());
    }
    return null;
}
protected void onPostExecute(String file_url) {
        pDialog.dismiss();
        ques1=new ArrayList<String>(new ArrayList<String>(ques1));
        imgarr=new ArrayList<String>(new ArrayList<String>(imgarr));
        TextView txtque = (TextView) findViewById(R.id.que_txt); 
        txtque.setText("Q" + num + ")" + ques1.get(j) + imgarr.get(g));
           }
php代码
      $group[$i]['image']= base64_encode(file_get_contents("http://10.0.2.2/question/images/".$row['image']));                                                                                                     
        $i++;
      array_push($response["group"], $group);