0

I wanna organise my code with subfolder into res folder for layout.

I know we cannot create subfolder into layout folder but i can create subfolder into res folder.

Now how can i SetContentView with my new folder.

-res/

---subfolder1_layout

-----sub1_layout.xml

---layout

-----layout.xml

And setcontentView (getClass().getResources("/res/subfolder1_layout/sub1_layout.xml")); does not work.

How can i do that please ?

Maxouille
  • 2,200
  • 2
  • 15
  • 38

2 Answers2

2

You can't do that.

Can the Android Layout folder contain subfolders?

Community
  • 1
  • 1
Vincent Mimoun-Prat
  • 26,900
  • 13
  • 74
  • 118
1

It's not possible directly.

Consider using a common name prefix for layouts belonging together so they sort together.

With the support of build tooling such as Gradle you can get have multiple resource folders in your project. Read more about resource merging.

laalto
  • 137,703
  • 64
  • 254
  • 280