谁能说我怎么能让这项工作好吗?
以下是他拍摄的照片: 什么时候开始
滚动时
我使用的代码 对于set adapter:
cs = new CursorSongs();
aa = new AdapterAlbum(a,cs.getAllAlbums(a));
gvAlbums.setAdapter(aa);
gvAlbums.setOnItemClickListener(this);
适配器:
public class AdapterAlbum extends CursorAdapter{
public AdapterAlbum(Context context, Cursor c) {
super(context, c,true);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
ViewHolder holder = (ViewHolder)view.getTag();
TextView tAlbum = (TextView)view.findViewById(R.id.tvAlbum);
ImageView iAlbum = (ImageView)view.findViewById(R.id.iAlbum);
tAlbum = holder.tAlbum;
iAlbum = holder.iAlbum;
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater i = LayoutInflater.from(parent.getContext());
View v = i.inflate(R.layout.detalle_grid, parent,false);
ViewHolder holder = new ViewHolder();
holder.tAlbum = (TextView)v.findViewById(R.id.tvAlbum);
holder.iAlbum = (ImageView)v.findViewById(R.id.iAlbum);
holder.tAlbum.setText(cursor.getString(cursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ALBUM)));
String coverPath = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ALBUM_ART));
Drawable img = Drawable.createFromPath(coverPath);
if(img != null){
holder.iAlbum.setImageDrawable(img);
}else{
holder.iAlbum.setImageResource(R.drawable.albumart_mp_unknown_list);
}
v.setTag(holder);
return v;
}
class ViewHolder{
TextView tAlbum;
ImageView iAlbum;
}