Android Notepad Example?


  1. PerfectReign

    PerfectReign Well-Known Member

    Having completed a few "Hello World" type apps for examples, I wanted to move on to a notepad style sample. Especially since my MyTouch doesn't have a notes application.

    Notepad Tutorial | Android Developers

    I - however - get many errors when loading even the solution. It keeps saying R. doesn't exist.

    [​IMG]

    Any ideas why this is? I don't notice a forum on the Developer Forums.

    Advertisement
  2. Jacob Malliet

    Jacob Malliet Active Member

    Do you have the layout in your res/layout/ folder?
  3. cp1

    cp1 Well-Known Member

    It was called notes_list in the example I followed -- they may have changed it since. Make sure you actually have the xml file in the right place and that it's saved (otherwise it won't automatically add the correct ID).

    If that doesn't work try project -> clean and there is another good one, something like "fix problems with project," but I can't find the menu option right now.

    ctrl-shift-o is always a good one to try, but I don't think that's the case here.
  4. PerfectReign

    PerfectReign Well-Known Member

    Thank you for the tip.

    I ran that, and it added an import line for the android.R class. However, I still get the error.

    I also noticed on the type-ahead that the notepad_list is not part of the R.layout class.

    [​IMG]
  5. oldman

    oldman Member

    A couple of things without seeing your full code:
    1. I find it best to always Save, Refresh and Clean
    2. After an error - delete the Out file that gets created (it will show up in the folder with the file that caused it (usually one of the xml's)
    3. Don't Import the R.class file
    4. Eclipse is very picky about syntax and when using the auto/suggestion, as in findViewById(R.id.layout) - type it in rather than using the suggestion - sometimes (not always) there seems to be a hidden character - trust me, I discoverer this many times. It's a bug.
    5. Regarding your specific problem: again back to 'syntax' Don't use: upper case, numbers or ANYTHING other than lowercase and no symbols or dashes or underlines. Especially for resources.
  6. cp1

    cp1 Well-Known Member

    It looks like you have another error below -- make sure all your errors are fixed first (especially brackets and semi-colons).

    Can you post a screenshot of your project files (expand the src and layout boxes).
  7. AmitNHB

    AmitNHB New Member

    I've also encountered the same problem with the second version of the notepad tutorial. For some reason it just doesn't generate the R.java class, which I assume is the cause of all the errors.
  8. santoshmadalli

    santoshmadalli New Member

    I looked into notepad application folders, there is no R.java present under gen folder.

    I think that is the reason why the error.

    I tried with Spinner appliaction which doesnt show up errors.
  9. jetak

    jetak New Member

    I am having the same problem and I also do not have the R.java file in /gen. My understanding is that the Android plugin for Eclipse is supposed to auto generate this file, it appears though that it has not. Is there a way to force Eclipse to generate this file? Thanks.

    P.S.
    I tried using the Android Tools-> Fix Project Properties, this did nothing. I aslo tried building the Solution, but there still was no /gen/R.java.
  10. nikhildl

    nikhildl New Member

    hello i am trying the notepad example 2 but the R.java file is not getting generated... it is giving an error as R.layout.Notes_list cannot be resolved...
    i am also getting an error in note_edit.xml file as multiple annotations found in LinearLayout
    pls help..
  11. GIR

    GIR Well-Known Member

    If you right click on the project directory, and then click on Android Tools near the bottom, there is a sub option to fix build, try this, for me in the past this has solved a few niggles, but dont expect miracles

    Hope this helps,
    GIR
  12. foofrog

    foofrog New Member

    check to see if you have import android.R; at the top of your source file. That was in mine, as soon as I removed it, I was able to access my own R variables.
  13. miXer

    miXer Well-Known Member

    i think the easiest way(maybe the only one) is to create a new project and start typing in the code from the example. This way the R java file is created on the start.
  14. versaggi

    versaggi New Member


    A BIG thanks ... that worked for me! Thanks again from across the pond! :)
  15. miXer

    miXer Well-Known Member

    I also did this tutorial for some time back, but i created the project from scratch, writing everything and had never any problems. I also strongly suggest people do this if they want to learn. To import a finished project is not so educationally as writing the project.
  16. dreamone

    dreamone New Member

    When creating the new project, try building against newer target; Android 2.2 (API Level 8). This can be selected at 'Build Target', assuming you have downloaded this version with the Android SDK Manager.

    Should work now!

Share This Page