• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps frmmensaje cannot be resolved or is not a field

Nacho22

Lurker
hi!!

I'm developing a really simple app with 2 activities, each one have to refer to a diferent .xml, but when I create a second document called (for example) layout2.xml, and then I try to refer it the function "setContentView(R.layout.frmmensaje);" I get this error message: frmmensaje cannot be resolved or is not a field. What am I doing wrong?

Thank you for your help and time
 
your xml file, in this case, is named layout2.xml, but you are trying to refer to it as R.layout.frmmensaje. This won't work. you need to refer to it by file name (w/o extension).

For example, if your layout xml file was named layout2.xml, you would refer to it in code as R.layout.layout2
 
Back
Top Bottom