请帮我看看 Android 记事本教程

发布于 2024-12-12 04:32:48 字数 562 浏览 0 评论 0原文

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

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

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

 asd

请帮助我找出我做错了什么,以便我可以继续下一步 训练。

我正在使用 Eclipse。

I've been trying to resolve an issue for a couple hours now, and can't seem to find a solution in the archives. I'm hoping some generous coder will help out a noob here.

I've been following the steps outlined in the Notepad tutorial, specifically "Notepadv1" located at this URL: http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

Even after confirming my code with that of the solution files, I am still seeing these errors.

asd

Please help me figure out what I've done wrong so I can move to the next step in the training.

I'm working with Eclipse.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

顾冷 2024-12-19 04:32:48

您遇到的问题是您的指南,不太清楚。它说:

最后,调用一个新方法 fillData(),它将获取数据并
使用助手填充 ListView - 我们还没有定义它
方法还没有。

他们在这里的意思是只定义一个不执行任何操作的方法,并且稍后将填充主体(见下文)。您可以按如下方式定义它:

private void fillData(){}

要实际填充它,请参阅指南中的步骤 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);
  }

The problem you are having is that Step 8, part 6 of your guide, is not really clear. It says:

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.

What they mean here, is to just define a method that does nothing, and they will fill-in the body later (see below). You can define it as follows:

private void fillData(){}

To actually populate it see step 12 in your guide:
Define the fillData() method, which should look like:

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);
  }
套路撩心 2024-12-19 04:32:48

显然您的活动中没有 fillData() 方法。

obviously you don't have a fillData() method in your activity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文