Android: Get resource ID by name always returns 0 -
i need resource id resource name. seek code resource id 0.
int drawableresourceid = this.getresources().getidentifier("test.png", "drawable", this.getpackagename()); system.out.println("resource id must "+r.drawable.test+" "+drawableresourceid);
output: "resource id must 2130837506 0."
any ideas?
your string shouldn't include file extension. seek this:
int drawableresourceid = this.getresources().getidentifier("test", "drawable", this.getpackagename());
also, getidentifier() method confusing in sec parameter type want (rather type of resource) if trying resource id, should this:
int drawableresourceid = this.getresources().getidentifier("test", "id", this.getpackagename());
android resources
No comments:
Post a Comment