I asked myselft the same question: can I export and reuse the layout in Android. I tried the following: export the project with XML resources to a JAR file, and then try to access the layout through it R.layout. Of course, this did not work, since R.layout.main was an integer, the same integer that was associated with a single layout (relative.xml) defined in the R.layout host project.
The kompiles Android SDK files host the XML files as View resources, and the XML files in the included JAR file are not xml layout files, they are not compiled, and the identifier is not associated with them in R.layout.
If you want to export a layout from your project, you must export it as XML and import it into a new project as a layout resource, and not as part of an external library.
If you want to reuse layouts from the JAR, you need to subclass the view and create the layout from the code. Then you can create an instance and install the created instance as an activity view or add an instance to your activity view.
Andras BalΓ‘zs Lajtha Oct 31 '10 at 20:18 2010-10-31 20:18
source share