我已经尝试解决一个问题几个小时了,但似乎无法在文件中找到解决方案。我希望一些慷慨的编码员能够帮助这里的菜鸟。
我一直在遵循记事本教程中概述的步骤,特别是位于此 URL 的“Notepadv1”:http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html
即使使用解决方案文件的代码确认了我的代码,我仍然看到这些错误。
请帮助我找出我做错了什么,以便我可以进入培训的下一步。
我正在使用 Eclipse。
最佳答案
您遇到的问题是 guide 的第 8 步第 6 部分,还不是很清楚。它说:
Finally, call a new method fillData(), which will get the data and populate the ListView using the helper — we haven't defined this method yet.
他们在这里的意思是只定义一个不执行任何操作的方法,并且稍后将填充正文(见下文)。您可以按如下方式定义它:
private void fillData(){}
要实际填充它,请参阅 guide 中的步骤 12 : 定义 fillData() 方法,该方法应如下所示:
private void fillData() {
// Get all of the notes from the database and create the item list
Cursor c = mDbHelper.fetchAllNotes();
startManagingCursor(c);
String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
int[] to = new int[] { R.id.text1 };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);
}
关于android - 请帮我看一下 Android 记事本教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7912851/