0

i'´m trying to load a list with just a local images and texts, everything works fine, i mean i can see the text fine but in the image field i can´t see the image.

the local images routes are "/mnt/sdcard/Imagenes/pic1.jpg/", "/mnt/sdcard/Imagenes/pic2.jpg/", etc.

i must be doing something wrong here and can´t figure out what is. any help would be appreciate, thanks...

Here is how i set the adapter to the list

FotosAdapter FotoAdapter = new FotosAdapter(this, R.layout.galeriafotos, listafotos);
listado.setAdapter(FotoAdapter);

and the adapter

public class FotosAdapter extends ArrayAdapter<Foto> {

    private ArrayList<Foto> items;


    public FotosAdapter(Context context, int textViewResourceId, ArrayList<Foto> items) {
        super(context, textViewResourceId, items);
        this.items = items;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ContenedorVista contenedor;

        if (convertView == null) {
            LayoutInflater infla = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infla.inflate(R.layout.galeriafotos, null);

            contenedor = new ContenedorVista();

            contenedor.txtObservacion = (TextView) convertView.findViewById(R.id.observaciones);
            contenedor.imgFotos = (ImageView) convertView.findViewById(R.id.fotosexpediente);

            convertView.setTag(contenedor);

        }else{
            contenedor = (ContenedorVista)convertView.getTag();
        }

        Foto o = items.get(position);

        if (o != null) {

            contenedor.txtObservacion.setText(o.getObservaciones());

            contenedor.imgFotos.setImageURI(o.getUriPath());


        }
        return convertView;
    }

    static class ContenedorVista{

        TextView txtObservacion;
        ImageView imgFotos;


    }

}

Here is how i set the array.

listafotos = new ArrayList();

            ImagesAdapter ia = new ImagesAdapter(Common.dbAdapter.getDatabase());
            Cursor cur =  ia.getFiltered(-1, -1, CodExp, null, null, Common.currentUser.getIdUsuario());
            cur.moveToFirst();
            while(!cur.isAfterLast()){

                try{
                    Foto objExpediente = new Foto();                    
                    objExpediente.setUriPath(Uri.parse(cur.getString(cur.getColumnIndex("Path")) + cur.getString(cur.getColumnIndex("_id")) + ".jpg")); 
                    objExpediente.setObservaciones(cur.getString(cur.getColumnIndex("Observaciones")));

                    listafotos.add(objExpediente);

                }catch(Exception ex){
                    Common.log("e",ex.toString());
                }
                cur.moveToNext();

            }
            cur.close();

Thanks a lot.

carlosrah
  • 1
  • 1

2 Answers2

0

For me it is to less information to help. What is missing in the code is the filling of the items-ArrayList.

When the text is displayed and the photo is not displayed, than this means that the last if-clause is entered. Try to put Log-Output into the last if-clause and output the URI you use.

Kind regards

ChrLipp
  • 15,526
  • 10
  • 75
  • 107
0

an URI for a file must start with "file://" so your seturi should probably be :

objExpediente.setUriPath(Uri.parse("file://" + cur.getString(cur.getColumnIndex("Path")) + cur.getString(cur.getColumnIndex("_id")) + ".jpg")); 
njzk2
  • 38,969
  • 7
  • 69
  • 107