【发布时间】:2011-09-16 14:00:41
【问题描述】:
我在使用 SQLite 数据库中的数据填充微调器时遇到问题。这是我的活动中的代码。 Activity 崩溃并出现 Unable to start Activity ComponentInfo 错误,箭头指示。
public class ProjectsActivity extends Activity {
private ReelDbAdapter dbHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.projects_select);
fillProjectSpinner();
}
private void fillProjectSpinner(){
// initialize cursor to manage data binding to spinner
Cursor projectCursor = null;
Spinner spnExistingProjects = (Spinner)findViewById(R.id.spnExistingProject);
---> projectCursor = dbHelper.getExistingProjects();
//startManagingCursor(projectCursor);
/*
//get the list of project names from the database
String[] from = new String[] {dbHelper.clmProjectName};
//add a new item to the spinner for each of the rows in the database
int [] to = new int[]{R.id.txtViewProjectRow};
//initialize a cursor adapter (similar to ArrayAdapter when populating a spinner from a pre-defined array)
SimpleCursorAdapter projectAdapter = new SimpleCursorAdapter(this, R.layout.view_project_row, projectCursor, from, to);
//add all the rows to the spinner
spnExistingProjects.setAdapter(projectAdapter);
*/
}
这是来自我的 dbAdapter 的 getExistingProjects 方法的代码 公共游标 getExistingProjects() {
if(mDb == null)
{
this.open();
}
return mDb.query(dbTableProject, new String[] {clmProjectName, clmProjectShootingTitle, clmProjectJobNumber},
null, null, null, null, null);
}
关于我可能做错了什么的任何线索? TIA 寻求帮助。 规范
【问题讨论】:
-
看起来不错,我们需要堆栈跟踪。
标签: android sqlite cursor spinner