android - 请帮我看一下 Android 记事本教程

标签 android android-layout

我已经尝试解决一个问题几个小时了,但似乎无法在文件中找到解决方案。我希望一些慷慨的编码员能够帮助这里的菜鸟。

我一直在遵循记事本教程中概述的步骤,特别是位于此 URL 的“Notepadv1”:http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

即使使用解决方案文件的代码确认了我的代码,我仍然看到这些错误。

asd

请帮助我找出我做错了什么,以便我可以进入培训的下一步。

我正在使用 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/

相关文章:

android - NDK 文件未与 Gradle Android 同步

android - 在 Android Wear 上实现 GridViewPager 的正确方法是什么?

android - 文字没有椭圆

android - 他们是如何制作这样的布局的——他们使用了哪些元素?

java - 使用 Retrofit 2 将图像从图库/相机上传到服务器(okhttp 问题)

android - 带有不可选择的灰色前缀的 EditText

java - 从 Internet 服务发送短信 - 无法接收广播以检查是否已发送短信

java - Ajax 响应中的 Set-Cookie header 不适用于 android webView

android - 让 ImageView 保持文本的正确大小,同时防止长文本将其推出 View ?

android - layout_height ="wrap_content"不适用于 android.support.design.widget.TabLayout