1

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?

Phil
  • 11
  • 2

3 Answers3

1

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!

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Oisin
  • 11
  • 1
0

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();
}
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
Shane
  • 1
  • 1
  • 1
    Remember that Java doesn't have functions, it has methods ("method" is defined as a function that belongs to a class... a "member function"). All functions belong to a class in Java, so we call them "methods". – Alex Lockwood Jun 01 '12 at 02:13
0

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.