package org.music.cs.adapter;
import java.util.List;
import org.music.cs.R;
import org.music.cs.entity.Music;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class ArtistsAdapter extends BaseAdapter {
private List<Music> listMusic;
private Context context;
public ArtistsAdapter(Context context, List<Music> listMusic) {
this.context = context;
this.listMusic = listMusic;
}
public void setListItem(List<Music> listMusic) {
this.listMusic = listMusic;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return listMusic.size();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return listMusic.get(arg0);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.music_item, null);
}
Music m = listMusic.get(position);
// ������
TextView textMusicName = (TextView) convertView.findViewById(R.id.music_item_name);
textMusicName.setText(m.getSinger());
// ����
TextView textMusicSinger = (TextView) convertView.findViewById(R.id.music_item_singer);
textMusicSinger.setText(m.getAlbum());
/*
* //����ʱ�� TextView textMusicTime=(TextView)
* convertView.findViewById(R.id.music_item_time);
* textMusicTime.setText(toTime((int)m.getTime()));
*/
return convertView;
}
}