進出口新的圖像到Android ..如何顯示從JSON對象字符串
林面臨着應用程序的問題..
我一直在試圖顯示我的JSON圖像的幾種方法,但我從來沒有解決方案成功了。
在我的數據庫中,圖像存儲在一個文件夾中。所以在我的JSON對象中,我得到了圖像的scr路徑。現在我想在emulator中顯示圖像。我在我的JSON對象中獲得了這樣的路徑:「imgsrc = question/images/u2_1_l2_q66」。我已經將路徑存儲在imgarr數組中。
如何從此路徑顯示圖像?我想添加圖像文件夾drawables.Please幫助我。非常感謝。
代碼
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));
}
請任何幫助我解決我的問題。真的,我不知道該怎麼做。 – 2013-02-19 10:01:25