自定义光标适配器未显示

时间:2014-03-11 10:50:11

标签: android android-cursoradapter

我从像这样的返回方法中获得了一个游标

Cursor result = dc.show(comp);

当我使用

读取值时
Log.i("cursor value1",result.getString(0)); 

我正确地得到它的价值 但我的适配器似乎无法正常工作

Cursor result = dc.showCompanyAndAdvertisee(comp);
MyAdapter adapter = new MyAdapter(this, result);
l.setAdapter(adapter);


class MyAdapter extends CursorAdapter{
LayoutInflater inflater;
Cursor c;

public MyAdapter(Context context, Cursor c) {
    super(context, c);
    inflater = LayoutInflater.from(context);        

}



@Override   
public void bindView(View view, Context arg1, Cursor c)    {
    TextView tv0 = (TextView)view.findViewById(R.id.singletextView1);

TextView tv1 = (TextView)view.findViewById(R.id.singletextView2);

TextView tv2 = (TextView)view.findViewById(R.id.singletextView3); 
    tv0.setText(c.getString(0));
    tv1.setText(c.getString(1));
    tv2.setText(c.getString(2));    }

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent)    {
    View row=inflater.inflate(R.layout.single,parent,false);
    return row;
}
}

0 个答案:

没有答案