Java Question Load XML layout in JAVA Library through B4A

Johnmcenroy

Active Member
Licensed User
Longtime User
I use the following function in my JAVA Library:

B4X:
public void setContentView(BA pBA, String LayoutName){
          pBA.activity.setContentView(BA.applicationContext.getResources().getIdentifier(LayoutName, "layout", BA.packageName));
      }

I have a layout in res/layout - layout.main.xml

So I compile my library and load in B4A
In B4A I type:
B4X:
Test.setContentView("layout.main.xml")

But I recieve in logs the following:
android.content.res.Resources$NotFoundException: Resource ID #0x0

Why ?

Thanks
 

warwound

Expert
Licensed User
Longtime User
Remove .xml from the layout name.

Martin.
Sent from my GT-I9300 using Tapatalk 2
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…