Notepadv2 教程无法正常工作 - “还没有笔记”,NoteEdit 类似乎没有被调用

发布于 2024-12-04 03:57:26 字数 301 浏览 3 评论 0原文

到目前为止,我与 Android Java 相处得很好,但现在我试图正确地做并学习记事本,但我迷失了。

当我从官方教程中运行 Notepadv2 时,我得到的屏幕与运行完整 v1 时得到的屏幕完全相同:“还没有注释”。没有“添加”选项,更不用说“编辑”了(当然,因为我没有添加注释)。

当我运行该解决方案时,也会发生同样的事情,并且到目前为止互联网对我没有帮助。

我最想知道的是,我一生都看不到 NoteEdit 类将在哪里被调用,并且我希望“添加”选项出现在notes_list.xml文件中......

帮助任何人?请?

so far I got along fine with Android Java, but now that I'm trying to do it right and learn the notepad I'm getting lost.

When I run the Notepadv2 from the official tutorials, I get exactly the same screen I get when I run the complete v1: "No Notes Yet". No "Add" option, let alone "Edit" (since I have not added notes, of course).

Same thing happens when I run the solution, and the internet won't help me so far.

What I'm wondering most about, I can't for the life of me see where the NoteEdit class would be called, and I would have expected the "Add" option to show up in the notes_list.xml file...

Help anyone? Please?

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

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

发布评论

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

评论(3

揽月 2024-12-11 03:57:26

如果您按“菜单”按钮,“添加注释”选项将从屏幕底部弹出,就像在编辑现有注释时使用菜单按钮弹出“删除注释”按钮一样。

如果你所有的代码都是可靠的,那么我想就差不多了。

NoteEdit 活动使用 onListItemClick 方法运行,当您单击创建笔记按钮时,

    Intent i = new Intent(this, NoteEdit.class);

    i.putExtra(NotesDbAdapter.KEY_ROWID, id);
    startActivityForResult(i, ACTIVITY_EDIT);

该方法开始一个新意图意图类将任何值传递给 NoteEdit 活动,并且 startActivityForResult 开始 NoteEdit 活动,

尽管我对此仍然陌生,所以任何人都可以纠正我,如果我错了!

If you press the Menu button the Add Note option pops up from the bottom of the screen, just as the delete note button pops up using the menu button when you're editing an already existing note.

If all your code is solid then I think thats pretty much it.

NoteEdit activity is ran with the onListItemClick method that begins a new intent when you click the create note button

    Intent i = new Intent(this, NoteEdit.class);

    i.putExtra(NotesDbAdapter.KEY_ROWID, id);
    startActivityForResult(i, ACTIVITY_EDIT);

The intent class passes whatever values to the NoteEdit activity and the startActivityForResult begins the NoteEdit activity

although im still new to this, so anybody do correct me if im wrong!

一刻暧昧 2024-12-11 03:57:26

我也有同样的问题。结果发现createNote方法是空的。实际上,如果您按照教程进行操作,则 createNote 方法将在第 4 步中填写。

如果您确实迫切希望看到您的应用程序运行,您可以暂时使 createNote 方法生效。代码>方法如下:

private void createNote() {
    String noteName = "New Note"; // similar to Notepadv1;
    mDbHelper.createNote(noteName, "");
    fillData();
}

I have the same problem too. It turned out that the createNote method is empty. Actually, if you are following the tutorial, the createNote method will be filled in step 4.

If you really have the burning desire to see your app work, you can temporarily make the createNote method like this:

private void createNote() {
    String noteName = "New Note"; // similar to Notepadv1;
    mDbHelper.createNote(noteName, "");
    fillData();
}
一张白纸 2024-12-11 03:57:26

这有点旧了,但我正在研究这个并遇到了同样的问题。如果您只是将插入选项添加到上下文菜单中,一切都很好:

public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, INSERT_ID,0, R.string.menu_insert);
    // menu.add(0, DELETE_ID,0, R.string.menu_delete);
    return true;
}

此外,我实际上相信他们意味着我们要添加插入选项而不是删除选项,并保存删除功能以便长按笔记。不管怎样,很高兴知道本教程没有让我们编写损坏的代码。干杯。

This is kinda old but I was working on this and ran across the same issue. If you just add the insert option to the context menu, everything is fine:

public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, INSERT_ID,0, R.string.menu_insert);
    // menu.add(0, DELETE_ID,0, R.string.menu_delete);
    return true;
}

Furthermore, I actually believe they meant for us to add the insert option rather than the delete option and save the delete functionality for a long press on a note. Either way, it's good to know the tutorial didn't have us writing broken code. Cheers.

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