Problem with Toasts


Hello All,

I have just started using this book and so far it has been fantastic…very easy to follow but I have encountered a problem :smiley:

As shown on page 23, I have added correct_toast and incorrect_toast in strings.xml . So far so good.

Then I added the code as shown on page 24 in listing 1.13 as shown below:

mTrueButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {


The error that I am getting is [quote]incorrect_toast cannot be resolved or is not a field [/quote]

How do I fix this error? I am guessing that I need to create an id for incorrect_toast but hos do I do that? Or am I missing something?

Many thanks for your help.

Best Regards



The only thing I can think is that either you spelled it wrong in the strings file (which should be caught by the IDE prior to runtime) or perhaps try to do a “clean” on your project as something didn’t get built correctly.


There’s most likely a typo or a misspelling of some sort, as the above poster said. In most cases when you need to do a “clean” or “build” on the project, it will say that “R” is a non-existent file, so a typo seems the most likely explanation.