Android:自定义适配器不调用getView方法

时间:2015-12-09 10:23:47

标签: java android adapter

我是Android新手,我检查过getCount()方法返回的值大于0,但{id}}和getView()方法都没有执行。

这是我的适配器类

getItem()

这是我的片段类

package com.zmlogisncs.fragment;

import java.util.List;

import com.zmlogisncs.dreamove.R;
import com.zmlogisncs.vo.AppointMent;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class AppointAdapter extends BaseAdapter {
private Context mContext;
private List<AppointMent> mList;

public AppointAdapter(Context context,List<AppointMent> list){
    mContext=context;
    mList=list;
}

@Override
public int getCount() {
    Log.d("ssss",mList.size()+"");
    return mList.size();
}

@Override
public Object getItem(int arg0) {
    return mList.get(arg0);
}

@Override
public long getItemId(int arg0) {
    return arg0;
}
@Override
public View getView(int poistion, View converView, ViewGroup parent) {
    if (converView==null) {
    converView=LayoutInflater.from(mContext).inflate(R.layout.appoitmentlistview_item, null);
    }
    Log.d("ssss", "ssss");
    return converView;
}

}

}

1 个答案:

答案 0 :(得分:0)

@Override
public long getItemId(int arg0) {
    return arg0;
}

将上述内容更改为

@Override
public long getItemId(int arg0) {
    return mList.indexOf(arg0);
}