I’m trying to display the image into android emulator 3.1, but i’m having a problem.
I only able to display URL into ListView.
I’m using my local server, and i arleady stored the url into mysql database and pass php, but now the problem is in android.
1) I need to convert image url into image and display it into ListView including text, here my code below :
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();
}
});
Please help me 🙂
This is what I was looking for :