Android 自定义光标适配器未显示
我从这样的返回方法中得到了一个游标Android 自定义光标适配器未显示,android,android-cursoradapter,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);
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;
}
}
有没有不使用SimpleCorsOrAdapter的原因?没有具体原因…但是你能告诉我其中的错误吗?似乎没问题,试试SCA,它更简单。你能告诉我如何为这个游标填充SCA的构造函数吗?请参阅