Skip to content Skip to sidebar Skip to footer

Unexpected File Added When Creating New Blank Activity In Android Studio

I got the new android studio, and I noticed one thing when creating a new blank activity. The layout that corresponds with the java for the activity is made twice, once as a cont

Solution 1:

Here content_menu is just a name for your xml layout content. Don't get confused by this. As you see in your Menu Activity you'll see setContentView(R.layout.activity_menu)

Here the activity is told that its layout is the content inside activity_menu.xml but in this(activity_menu.xml) file you see an include tag. the include tag means that the content inside another xml file named content_menu.xml must be included inside the current layout at the place where include tag is used. so if want to change the internal content you can leave everything in activity_menu.xml as it is and make your changes in content_menu.xml and it'll all be visible in your design.

and if you don't want the content_menu.xml file you can just copy everything from this file to activity_menu.xml in place of <include > tag and delete the content_menu.xml file.

Solution 2:

Say for example you want to reuse content_menu.xml content somewhere else, in that case in other activity you will do the same include statement in xml file. The point is that you are reusing the same xml and reducing number of content.

Post a Comment for "Unexpected File Added When Creating New Blank Activity In Android Studio"