使用 Chris Banes 的 PullToRefresh 库,我的自定义适配器的 getView() 方法没有被调用。这段代码在不使用他的库的情况下工作正常,并且调用了 getView()。我已经研究了几天了,无法弄清楚出了什么问题。任何反馈将不胜感激!
我的活动.java
MyAdapter adapter = new MyAdapter(this, data);
// the following toast displays the correct count
Toast.makeText("MyActivity", adapter.getCount(), Toast.LENGTH_SHORT).show();
myListView.setAdapter(adapter);
我的适配器.java
public class MyAdapter extends ArrayAdapter<Object> {
private ArrayList<Object> data;
private LayoutInflater vi;
private Context context;
public MyAdapter(Context context, ArrayList<Object> data) {
super(context, 0);
this.context = context;
this.data = data;
this.vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
static class ViewHolder {
...
}
@Override
public int getCount() {
return data.size();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// not getting called
...
}
}