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 = 新しい 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-clause に入れて、使用する 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 に答える