Reputation: 4408
I have very strange issues in my application. I added a layout file with name add_new_item and i got an exception. I was not even setting this xml file as content in any activity. And the exception was coming in a library function which was not touched. So while trying to find the root cause, i just tried to renaming the file to a name like "data_entry_form" and to the exception was gone !
After that again i am facing a strange similar issuse. I have a button with image name "add_new_itm". I have a layout with 4 buttons one of which is this button. After setting this layout if i click any of those buttons to reach another activity, change the phone orientation and comeback to this activity with 4 buttons and again press any of the button then wahtever layout is displayed, it has "add_new_item" image as background. ie layout with 4 buttons ( 4th one is add_new_item ) -> press button 1 take to new screen -> rotate phone-> comeback to layout with 4 buttons -> press button 1 again -> the screen will have add_new_item image as background occupying complete screen.
Now i tried just renaming the image, the button, and everything works fine.
Can you please explain this strange behaviour
Upvotes: 0
Views: 128
Reputation: 40218
These things probably happen because the fact that if you're using a library for your project, which contains layout files, the names of your layout files and the library layouts should not overlap. The compiler generates a single R.java file for both your and library layouts, and it won't be able to do it if the files have the same names. Hope this helps.
Upvotes: 1