Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to regenerate the R.java file. One way to do this is to rebuild the project.
 
Ranch Hand
Posts: 37
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic