2011-08-07 9 views
0

최근에 나는 android and java development 일반적으로 프로그래밍을 시작했습니다. 현재는 시간표 앱을 작성하여 교육합니다. 나는 db의 모든 과목 (선생님과 방도 들어있는 테이블) 목록을 가져 와서 회 전자에 넣기를 원합니다. 그게 전부 코드가 나는 문제는 스피너를 클릭 할 때의 데시벨이 항목이만큼 항목 목록을 보여줍니다,하지만 이름이 표시되지 않습니다 목록 (당신이 그것을 말할 수 있다는 것입니다 db 쿼리로 회 전자 채우기

Cursor c = dba.fetchAllSubjects(); 

if (c.getCount() != 0) { 
    Spinner subjectSpinner = (Spinner) findViewById(R.id.newlesson_subject); 
    startManagingCursor(c); 
    String[] from = new String[]{DbAdapter.KEY_SUBJECT}; 
    int[] to = new int[] {android.R.layout.simple_spinner_item}; 
    SimpleCursorAdapter subjectAdapter = 
     new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from, to); 
    subjectSpinner.setAdapter(subjectAdapter); 
} 

을 썼다 빈). 그래서 나는 아마도 간단한 커서 어댑터로 뭔가를 엉망으로 만들었지 만, 나는 무엇을 모르고있다.

덕분에 당신의 도움

답변

0

을 위해 당신은 오류가 정수 배열에 잘못된 리소스 ID를 지정에 자리 잡고있어.

int[] to = new int[] {android.R.layout.simple_spinner_item}; 

레이아웃 자체가 아니라 TextView (또는 유사한 입력보기)의 ID를 지정해야합니다. 위의 행을 다음으로 바꿉니다.

int[] to = new int[] { android.R.id.text1 };