데이터베이스의 정보로 채워야하는 스피너가 있지만 찾은 예제가 작동하지 않습니다. 당신이 밖으로 코드를 떠나지 않았어요 가정스피너를 데이터베이스 정보로 채우는 방법
public void consulta() {
AdminSQLiteOpenHelper admin =
new AdminSQLiteOpenHelper(this, "administracion", null, 1);
SQLiteDatabase bd=admin.getWritableDatabase();
Cursor c = bd.rawQuery("select name from category",null);
startManagingCursor(c);
// create an array to specify which fields we want to display
String[] from = new String[]{"name"};
// create an array of the display item we want to bind our data to
int[] to = new int[]{android.R.id.text1};
// create simple cursor adapter
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from, to);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// get reference to our spinner
spinner1.setAdapter(adapter);
bd.close();
}
"작동하지 않음"(오류 로그 게시, 스택 추적 등 ...)을 정의하십시오. 그리고 오신 것을 환영합니다! – Jack
어디에서 'spinner1'을 정의합니까? – Sam
감사합니다 이것은 훌륭한 웹입니다. 많은 정보를 얻었습니다. 저는 안드로이드에서 초보자입니다. 문제는 내가 애플 리케이션을 실행할 때 회 전자 아무것도 채우지 않을 것입니다하지만 만약 내가 그 정보를 가지고 listview 또는 그것을 textview에서 그것을 캐스팅, 나는 스피너 채우기 메서드가 다른 개체보다 다른 경우 알 수 없다 – dakairus