我正在尝试创建一个带有空选择的微调器,但问题是我正在从 SQLite 数据库加载我的微调器。这是我用来加载微调器的代码:
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);
}