I found a frequently encountered problem today. After creating a new activity class, I used setcontentview () to load the layout or ID in the XML file I wrote,
Sometimes I find that I cannot connect to the corresponding ID. Of course, compilation is not passed through. Check the r file and find that the layout and id I want to reference exist, but it is
R. layout. mylayout cannot be connected.
Cause: the r package I imported is incorrect. Because R. layout is selected as the shortcut key, the system will import the r package (import Android. R) that comes with Android ),
As a result, R. layout. mylayout cannot be used to load the custom mylayout.
Solution: remove import Android. R and import the r file package path under the project, for example, package com. lancorp. relativelayout. R;
Conclusion: When Using Smart prompts to generate a post, pay attention to whether the path of the resource is needed. Because Android defines many classes, it is inevitable that some class names
But the packages of these two classes are definitely different, so pay more attention to the path where the resources are located.
It's hard to learn about Android.