我試圖將圖像顯示到android模擬器3.1,但我遇到了問題。 我只能將URL顯示到ListView中。 我正在使用我的本地服務器,我arleady存儲到MySQL數據庫的URL並通過PHP,但現在的問題是在Android。將圖像URL轉換爲圖像Android
1)我需要圖像URL轉換爲圖像並顯示到ListView控件包括文本,在這裏我下面的代碼:
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
JSONObject json = JSONfunctions.getJSONfromURL("http://10.0.2.2/php/ViewPro.php");
try{
JSONArray earthquakes = json.getJSONArray("prop");
for(int i=0;i<earthquakes.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = earthquakes.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("imageColumn","Property : " + e.getString("imageColumn"));
map.put("P_Price","Property Cost : " + e.getString("P_Price"));
mylist.add(map);
}
}catch(JSONException e) {
Log.e("log_tag", "Error parsing data "+e.toString());
}
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.list_item, new String[] {"imageColumn","P_Price"}, new int[] { R.id.item_title, R.id.item_subtitle });
setListAdapter(adapter);
final ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@SuppressWarnings("unchecked")
HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);
Toast.makeText(ViewStock.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show();
}
});
請幫我:)
您可以編輯你的問題,使代碼的格式正確?當人們可以輕鬆閱讀你在做什麼時,你可能會得到更好的迴應。 – jprofitt