I was trying to work out with multiple layout using some online tutorials. The thing is my program was building and compiling correctly as long as there was only one XML fil
After cleaning the project and syncing with gradle(no result), i removed all my import statement, and brought them back in using alt+Enter.
I had the same problem, fixed by replacing R
with com.example.appname.R
obviously put your package reference in there instead. Or just add this line to your file:
import com.your.package.R
Or even better, try removing this line from your code if exists:
import android.support.compat.R
or you can write
import.R.layout // at the top
It will work for sure
First Doing This --> Select Build > Clean Project from the Android Studio toolbar, wait a few moments, and then build your project by selecting Build > Rebuild Project.
if Problem Not solved then doing This --> File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio’s toolbar.
JUST REMOVE the import.android.R;
Then the R.layout.(XML LAYOUTNAME) will turn to BLUE
IT TOOK ME HOURS TO FIND THIS ONE ERROR
Either your gradle or build need to know where resources are.