Android compresses the Activity into a jar package for third parties to completely solve the problem that XML image text resources cannot be entered into the jar package sadly !, Androidjar
To create a project, you need to package the program into a jar file for the third party to use the project requirements (write the image text resources to the jar package, when the Third Party calls, you only need to in AndroidManifest. in xml configuration, the corresponding Activity is pulled through StartActivity): After searching for the Activity on the Internet for a long time, and finally solved the problem by viewing the Android source code.
I. knowledge needed:
1. The Res directory in the APK cannot be imported to the jar package using the Export method of Eclipse, while Assert can
2. When compiling an Android program into APK, you need to use aapt to generate the corresponding Id for resources under the Res directory, while resources under the Assert directory do not generate an Id in the R file.
Learning XML resources:
1. The XmlResourceParseropenXmlResourceParser (String fileName) method is provided in AssetManager. This method can be used to generate a resource traversal object in the compiled XML file. This object can be used to obtain a View tree of the entire layout.
2. You can set the Activity layout in the Oncrea method through setContentView (view ).
Learning image resources:
1. Put a non-. 9 image in the Assert directory. You can use StateListDrawable to obtain file resources to generate the click effect of the Drawable object, such as the Button, and other spaces.
2. process the. 9 image so that you need to compile it first to remove the labels of the black stretch area display area from the upper and lower sides. The usage is consistent with that of the Non-. 9 image.
Character Learning
1. Write the characters in the Java file and write them to a static Map. The kay_value can be obtained globally.
II. Specific operation process:
1. Set your layout in the XML file and view the interface effect in the running Activity first.
2. delete the image and Font Resource attributes you set in the XML file. Because the Res directory cannot be imported into the Jar package and the Id of the corresponding resource cannot be generated in the R file, you can use android: src = "@ drawable/uac_logo" the image resources set in this mode will not be found. When a third party obtains the compiled XMLlayou file, it will throw the exception that the resource has not been taken.
2. Extract the compiled APK file from the bin directory, decompress the compiled XML file, and put the image resource into the Assert directory.
3. use XmlResourceParseropenXmlResourceParser (String fileName) in the onCreat method of the Activity to obtain the Layout file. Use setContentView (view) to set it to the Layout of the entire Activity and use the controls (such as ButtonTextView) you can still use the R. id. in this case, the system parses the XML file and obtains the control IDs in your XMl file (whether the Id conflicts with the third-party resource Id at this time, after all, the definition provided by findViewById () is to find the Id of the control in the XML. Which of the following is a clear question ?)
4. After obtaining the control, you can use setTextsetBackground setImageDrawable and other methods to set the foreground resources of the text background.