0

我正在尝试加载仅包含本地图像和文本的列表,一切正常,我的意思是我可以很好地看到文本,但在图像字段中我看不到图像。

本地图像路由是“/mnt/sdcard/Imagenes/pic1.jpg/”、“/mnt/sdcard/Imagenes/pic2.jpg/”等。

我一定在这里做错了什么,无法弄清楚是什么。任何帮助将不胜感激,谢谢...

这是我将适配器设置为列表的方法

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

和适配器

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;


    }

}

这是我设置数组的方式。

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();

非常感谢。

4

2 回答 2

0

对我来说,帮助的信息更少。代码中缺少的是items-ArrayList的填充。

当显示文本而不显示照片时,这意味着输入了最后一个 if 子句。尝试将 Log-Output 放入最后一个 if 子句并输出您使用的 URI。

亲切的问候

于 2011-09-19T10:23:21.827 回答
0

文件的 URI 必须以“file://”开头,因此您的 seturi 可能应该是:

objExpediente.setUriPath(Uri.parse("file://" + cur.getString(cur.getColumnIndex("Path")) + cur.getString(cur.getColumnIndex("_id")) + ".jpg")); 
于 2011-09-19T10:57:54.043 回答