我試圖創建一個空選擇的微調,但問題是我從SQLite DataBase加載我的微調。這裏的代碼我使用加載微調:Spinner從SQLite DataBase填充空選擇
public void loadSpinnerDataRegion() {
DataBaseHelper myDbHelper = new DataBaseHelper(this);
myDbHelper = new DataBaseHelper(this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
// Spinner Drop down elements
RegionList=myDbHelper.getAllRegion();
// Creating adapter for spinner
ArrayAdapter<String>dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,RegionList);
// Drop down layout style - list view with radio button
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// attaching data adapter to spinner
spinner2.setAdapter(dataAdapter);
}
這是行不通的,NullPointerException異常 – lolita 2013-05-05 12:53:12
@lolita發表您的logcat的痕跡...... – Pragnani 2013-05-05 12:53:54