package com.example.yingyuee;import java.util.List;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 MusicListViewAdapter extends BaseAdapter { private List<Music> mData; private Context mContext; private LayoutInflater mInflater; public MusicListViewAdapter(List<Music> musics,Context context) { // TODO Auto-generated constructor stub this.mData=musics; this.mContext=context; mInflater=LayoutInflater.from(context); } @Override public int getCount() { // TODO Auto-generated method stub return mData=null?0:mData:size(); } @Override public Object getItem(int location) { // TODO Auto-generated method stub return mData=null? null:mData.get(location); } @Override public long getItemId(int location) { // TODO Auto-generated method stub return location; } class Holder{ TextView singer; TextView title; } public View getView1(int position, View coverView, ViewGroup parent) { // TODO Auto-generated method stub Holder holder; if(coverView==null) { coverView=mInflater.inflate(R.layout.music_list, null); holder=new Holder(); holder.singer=(TextView)coverView.findViewById(R.id.music_singer); holder.title=(TextView)coverView.findViewById(R.id.music_name); coverView.setTag(holder); }else { holder=(Holder)coverView.getTag(); } holder.title.setText(mData.get(position).getTitle()); holder.singer.setText(mData.get(position).getTitle()); return coverView; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub return null; }}
- 4 回答
- 0 关注
- 1347 浏览
添加回答
举报
0/150
提交
取消