猿问

请问下大家,为何总提示错误,是没定义什么值吗

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;

}


}


mst0
浏览 1348回答 4
4回答

雨花亭

这个明显缺少了music实体封装类啊

公子小白3474636

没有创建Bean类music

GdinKing

很明显你没有导入Music所在的包

蜂之谷

没导包吧
随时随地看视频慕课网APP

相关分类

Android
我要回答