Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use main xml file in layout-land folder ?

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
normally we put main xml file in res/layout folder.
I have a main file in res/layout-land folder.I need to use that file as main xml.so which code need to change ?
i have attached a screenshot also below.

main.jpg
[Thumbnail for main.jpg]
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can name the files in res/layout anything that you like, for example: altscreen.xml Then in R.java you will get constant within the "layout" with the XML file's name, for example:



Then use that in your activity's onCreate method:

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have alrady created a main xml in res/layout-land folder.but there is no any specific variable created for that in R java class.
below is R java class

below is my screenshot .look there is main xml file located in res/layout folder
lay.jpg
[Thumbnail for lay.jpg]
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to regenerate the R.java file. One way to do this is to rebuild the project.
 
Mayu Mayooresan
Ranch Hand
Posts: 37
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to refer the layout-land but your code refers R.layout.main

so the layout shown will be the main.xml file under layout folder.

btw avoid using - in folder file names, it'll create compilation error most of the time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic