안드로이드 개발 질문/답변
(글 수 40,700)
자동완성 기능의 데이타를 디비에서 추출해서 리스트로 나타내려고 합니다.
일단
ui_location = (AutoCompleteTextView) findViewById(R.id.busstop_stoplookupLocation); 이게 객체고요
커서는 아래와 같고요.. mDbHelper에서 디비 데이타를 뽑아옵니다.
Cursor locationCursor = mDbHelper.fetchAllNotes();
startManagingCursor(locationCursor);
그담에 SimpleCursorAdapter을 사용해서 아래와 같이 셋리스트어뎁터를 불렀더니만 에러가 나네요.. ㅠㅠ
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.simple_dropdown_item_1line, locationCursor, null);
setListAdapter(notes);
노트패드 예제에 보면 심플커서어탭터 사용해서 디비정보 출력하던데.. 왜 자동완성에서는 저게 안먹힐까요
to 파라미터는 없어서 널로 했는데...
혹시나 해서 어댑터를 직접 아래처럼 만들어봤는데도 안됩니다. 뭐가 문제일까요... 조언좀 주세요.. 감솨..
일단
ui_location = (AutoCompleteTextView) findViewById(R.id.busstop_stoplookupLocation); 이게 객체고요
커서는 아래와 같고요.. mDbHelper에서 디비 데이타를 뽑아옵니다.
Cursor locationCursor = mDbHelper.fetchAllNotes();
startManagingCursor(locationCursor);
그담에 SimpleCursorAdapter을 사용해서 아래와 같이 셋리스트어뎁터를 불렀더니만 에러가 나네요.. ㅠㅠ
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.simple_dropdown_item_1line, locationCursor, null);
setListAdapter(notes);
노트패드 예제에 보면 심플커서어탭터 사용해서 디비정보 출력하던데.. 왜 자동완성에서는 저게 안먹힐까요
to 파라미터는 없어서 널로 했는데...
혹시나 해서 어댑터를 직접 아래처럼 만들어봤는데도 안됩니다. 뭐가 문제일까요... 조언좀 주세요.. 감솨..
public class CustomACAdapter extends CursorAdapter { private LocationDbAdapter mDb; public CustomACAdapter(Context context, Cursor c) { super(context, c); mDb = new LocationDbAdapter(context); mDb.open(); } @Override public void bindView(View view, Context context, Cursor cursor) { ((TextView)view).setText(cursor.getString(1)); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { final LayoutInflater inflater = LayoutInflater.from(context); final TextView view = (TextView) inflater.inflate( android.R.layout.simple_dropdown_item_1line, parent, false); view.setText(cursor.getString(1)); return view; } }