I have a question,everyone.
I want to use getResource.getIdentifier()
to get my layout element in XML (layout/xxx.xml).
But I am encounter \" R
With this:
int layoutID = getResources().getIdentifier("layout"+n, "layout", getPackageName());
you basically retrieve the id of a layout file that you can inflate. It's the dynamic version of
int layoutID = R.layout.layout1;
What you intend to do is retrieve a view from an already inflated layout. That's how you'd do it:
int layoutID = getResources().getIdentifier("layout"+n, "id", getPackageName());
return (LinearLayout)findViewById(layoutID);
That's the dynamic version of
return (LinearLayout)findViewById(R.id.layout1);