我正在尝试将图像显示到 android 模拟器 3.1 中,但我遇到了问题。我只能在 ListView 中显示 URL。我正在使用我的本地服务器,并且我已经将 url 存储到 mysql 数据库并传递 php,但现在问题出在 android 中。
1)我需要将图片网址转换为图片并将其显示到包含文本的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();
}
});
请帮我 :)