Les dejo un problema que no puedo solucionar a ver si me dan una mano.
Tengo mi un listview en un fragment que se cargo con los datos de una base por medio de Json..
Los datos los muestro sin problema pero no puedo mostrar la Imagen..
Muchas gracias de antemano y les dejo el codigo.. Saludos
Código:
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public class Fm_Listado extends Fragment { private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser = new JSONParser(); ArrayList<HashMap<String, String>> empresaList; // url to get all products list public static String url_all_empresas = "http://basedecomercios.pe.hu/charconect/get_all_Contactos.php"; // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_COMERCIOS = "comercios"; private static final String TAG_ID = "id"; private static final String TAG_NOMBRE = "Nombre"; private static final String TAG_TELEFONO = "Telefono"; private static final String TAG_DIRECCION = "Direccion"; private static final String TAG_EMAIL = "Email"; private static final String TAG_IMG = "Link"; private ImageView imageView123; private Bitmap loadedimage; private String linkdeimagen; private String url; // products JSONArray JSONArray products = null; ListView lista; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fr_listado, container, false); return rootView; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Hashmap para el ListView empresaList = new ArrayList<HashMap<String, String>>(); // Cargar los productos en el Background Thread new LoadAllProducts().execute(); lista = (ListView) getView().findViewById(R.id.listAllProducts); imageView123 =(ImageView)getView().findViewById(R.id.imagenLocal); } private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageView bmImage; public DownloadImageTask(ImageView bmImage) { this.bmImage = bmImage; } protected Bitmap doInBackground(String... urls) { String urldisplay = urls[0]; Bitmap mIcon = null; try { InputStream in = new java.net.URL(urldisplay).openStream(); mIcon = BitmapFactory.decodeStream(in); } catch (Exception e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return mIcon; } protected void onPostExecute(Bitmap result) { bmImage.setImageBitmap(result); } } //-----------------------------Base remota Funciones Json class LoadAllProducts extends AsyncTask<String, String, Bitmap> { /** * Antes de empezar el background thread Show Progress Dialog */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(getActivity()); pDialog.setMessage("Cargando comercios. Por favor espere..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } /** * obteniendo todos los productos */ protected Bitmap doInBackground(String... args) { // Building Parameters //List params = new ArrayList(); List<NameValuePair> params = new ArrayList<NameValuePair>(); // getting JSON string from URL JSONObject json = jParser.makeHttpRequest(url_all_empresas, "GET", params); // Check your log cat for JSON reponse Log.d("All Products: ", json.toString()); try { // Checking for SUCCESS TAG int success = json.getInt(TAG_SUCCESS); if (success == 1) { // products found // Getting Array of Products products = json.getJSONArray(TAG_COMERCIOS); // looping through All Products //Log.i("ramiro", "produtos.length" + products.length()); for (int i = 0; i < products.length(); i++) { JSONObject c = products.getJSONObject(i); // Storing each json item in variable String id = c.getString(TAG_ID); String Nombre = c.getString(TAG_NOMBRE); String Direccion = c.getString(TAG_DIRECCION); String Telefono = c.getString(TAG_TELEFONO); String Email = c.getString(TAG_EMAIL); String Link = c.getString(TAG_IMG); // creating new HashMap HashMap map = new HashMap(); // adding each child node to HashMap key => value map.put(TAG_ID, id); map.put(TAG_NOMBRE, Nombre); map.put(TAG_DIRECCION, Direccion); map.put(TAG_TELEFONO, Telefono); map.put(TAG_EMAIL, Email); map.put(TAG_IMG, Link); empresaList.add(map); } } } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * * */ protected void onPostExecute(Bitmap file_url) { // dismiss the dialog after getting all products pDialog.dismiss(); // updating UI from Background Thread getActivity().runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( getActivity(), empresaList, R.layout.single_post, new String[]{ TAG_ID, TAG_NOMBRE, TAG_DIRECCION, TAG_TELEFONO, TAG_EMAIL, TAG_IMG, }, new int[]{ R.id.single_post_tv_id, R.id.single_post_tv_nombre, R.id.single_post_tv_direccion, R.id.single_post_tv_telefono, R.id.single_post_tv_email, R.id.imagenLocal, }); // updating listview //setListAdapter(adapter); lista.setAdapter(adapter); } }); } } }