Use Build | Make. Actually, IDEA generates R.java file automatically every time you make a change in any XML file under the /res directory.
UPDATE: /gen directory must be present in the project and also configured as a Source root in IDEA module so that it can resolve the IDs in your source code.