사용자 정의 CursorAdapter
을 작성하려고합니다. DBAdapter
클래스의 데이터베이스를 설정했습니다. 나는 가지고있다 :CursorAdapter에 커서를 설정하는 기능이없는 것 같습니다.
public class ExampleCursorAdapter extends CursorAdapter {
public ExampleCursorAdapter(Context context, Cursor c) {
super(context, c);
}
public void bindView(View view, Context context, Cursor cursor) {
TextView summary = (TextView)view.findViewById(R.id.label);
summary.setText(cursor.getString(
cursor.getColumnIndex(DBAdapter.question)));
}
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.more_results, parent, false);
bindView(v, context, cursor);
return v;
}
}
내가 ExampleCursorAdapter
의 인스턴스를 만들고있는 상세한 피드백 클래스가있다. 내가 가지고있는 문제는 CursorAdapter
을 설정하는 데 아무 것도없는 것 같습니다.
public class DetailedFeedback extends ListActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Cursor c = db.getAllContacts();
ExampleCursorAdapter adapter = new ExampleCursorAdapter(this, c);
setListAdapter(adapter);
}
}
올바른 구문인지 확실하지 않습니다.
내가 반환하려고하는 열과 동일하게 만들 수 있습니까? – al23dev
@Alexander 데이터베이스에서 쿼리하는 방법을 알고 있습니까? '_id' 및'DBAdapter.question' 열에 대해 데이터베이스에 쿼리를 한 후에 커서를 반환합니다. – Luksprog
커서에 무엇을 할당 할 것인지 잘 모르겠다. – al23dev