1

res/layout ---layout/subfolder1 ---layout/subfolder2 is it right way to create sub folder inside layout folder in Android

and how to get id of layout from that sub folder.

Example:

res/layout ---layout/main.xml]

setContentView(R.layout.main);

3 Answers 3

2

You cant do that. I mean you can create folders if you want to but you can access them like "R.layout.sub1.layoutfile".

4
  • Yes. you can create a sub folder but you cant access thats why you have to put all the files inside root folder.
    – mudit
    May 20, 2011 at 7:14
  • dude.. do you have problems in reading english. I have told you this thing twice and some other guys too that it is not possible in android application development. At least not yet.
    – mudit
    May 20, 2011 at 9:28
  • if we can create why we can not access there is not any way to access that folder in activity
    – Amitsharma
    Feb 21, 2014 at 11:29
  • i have same this type problem ... i have different packages now i have many files of activity layout i want to manage these files of layout in different folder and access these layouts ...if u have any idea to do that ....
    – Amitsharma
    Feb 21, 2014 at 11:31
1

You can't do that. All you layout files must be in the root of the layout folder.

3
  • But you can always add some stuff to the name of the file to help. Like dashboard_center.xml ; login_header.xml etc. May 19, 2011 at 9:57
  • hello , my project have 1000 of layout file i am unable to manage all files in one layout folder so please help me if you have any other solution please replay me.... May 19, 2011 at 10:35
  • @Prashant Kadam Even Android source code contains only 100+ layout files, so I think 1000 is too many for a mobile app. If you really think you need all this files, you can extract some parts of you project to external Android Library projects. Then you'll be able to include these libraries to your project. But it will not solve your problem, because layout files in different libraries mustn't have equal names. So, as NeTeInStEiN said, just use prefixes.
    – Michael
    May 19, 2011 at 12:19
0

I don't think this is possible. yaa you may create folder for landscape layout. path will be : res> layout-land (folder name)

1
  • hello , my project have 1000 of layout file i am unable to manage all files in one layout folder so please help me if you have any other solution please replay me.... May 19, 2011 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.