2016-10-10 21 views
0

カメラから画像を取得してフォルダに保存し、SQLiteデータベースに格納されているアプリケーションがリストビューに表示されますが、スクロールすると、 ListViewの動きは非常に遅いです。sdcardに保存された画像のリストビューは遅いです

Androidのモニターは私に次のメッセージ

あなたのメインスレッド上であまりにも多くの仕事を行うことができるアプリケーションを示しています。

私は、AsyncTaskを実行すると問題が解決することを読んだことがあります。私はAsyncTaskを使用してイメージのパスを取得する方法を知りたいと思います。

がここにここに私のAsyncTask

public class getImageTask extends AsyncTask<PropiedadCursorAdapter.ViewHolder, Void, Bitmap> { 

private PropiedadCursorAdapter.ViewHolder v; 


@Override 
protected Bitmap doInBackground(PropiedadCursorAdapter.ViewHolder... params) { 
    v = params[0]; 
    return null; 
} 

@Override 
protected void onPostExecute(Bitmap bitmap) { 
    super.onPostExecute(bitmap); 
    String cadena = PropiedadDbAdapter.C_COLUMNA_IMAGENES; 

} } 

おかげ

+0

あなたはどのようにしてパスを取得しますか? – XxGoliathusxX

+0

ViewHolder holder =(ViewHolder)view.getTag();文字列cadena = cursor.getString(cursor.getColumnIndex(PropiedadDbAdapter.C_COLUMNA_IMAGENES)); Picasso.with(context).load(cadena).into(holder.ivCasa); –

+0

私はそれを行う方法がわかりません。 –

答えて

0

あなたはbindViewデータ収集におけるアダプタに行くべきではないです私のコード

public class PropiedadCursorAdapter extends CursorAdapter{ 

private PropiedadDbAdapter dbAdapter =null; 

public PropiedadCursorAdapter (Context context, Cursor c){ 
    super(context, c); 
    dbAdapter = new PropiedadDbAdapter(context); 
    dbAdapter.abrir(); 
} 

@Override 
public View newView(Context context, Cursor cursor, ViewGroup parent) { 

    View view =((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.layout_lista_propiedades,parent,false); 
    ViewHolder holder = new ViewHolder(); 
    holder.ivCasa = (ImageView) view.findViewById(R.id.ivCasa); 
    holder.tvTitulo= (TextView) view.findViewById(R.id.tv_titulo); 
    holder.tvUbicacion= (TextView) view.findViewById(R.id.tv_ubicacion); 

    view.setTag(holder); 
    return view; 
} 

static class ViewHolder { 
    ImageView ivCasa; 
    TextView tvTitulo; 
    TextView tvUbicacion; 
} 

@Override 
public void bindView(View view, Context context, Cursor cursor) { 

    ViewHolder holder = (ViewHolder) view.getTag(); 
    String cadena = cursor.getString(cursor.getColumnIndex(PropiedadDbAdapter.C_COLUMNA_IMAGENES)); 
    Picasso.with(context).load(cadena).into(holder.ivCasa); 

    holder.tvUbicacion.setText(cursor.getString(cursor.getColumnIndex(PropiedadDbAdapter.C_COLUMNA_DESCRIPCION))); 
    holder.tvTitulo.setText(cursor.getString(cursor.getColumnIndex(PropiedadDbAdapter.C_COLUMNA_TITULO))); 
}} 

ですが、完全なデータの初期化を要求する必要があり、 Beanのパッケージに格納してからAdapterに設定すると、速度がはるかに速くなります。

関連する問題