The Android Custom component is implemented as a jar package , where you handle the jar package for your own implementation of the Android View component.
In the process of project development, we will inevitably use their own to make custom view control, then our other projects if necessary, directly copy it to the corresponding project to use, although this is a solution to the problem, but after all not very good.
The reason is that when our projects accumulate more and more, and we find that there are more and more custom controls, and that these custom controls are reusable, we can think about if you encapsulate these custom controls into a jar package and then accumulate them in one project, After we develop the project as long as the original jar package based on the expansion or direct use, can greatly reduce their duplication of work.
First, the basic features of Android engineering are this:
Of course, the corresponding activity file was deleted by me because we didn't need an activity file when compiling into a jar package.
Taking the above project as an example, we package it as a jar package step:
Right-key project selection export:
Select the export target: Java->jar file:
Check out some unnecessary files, as shown below:
To this step, has been basically completed, browse the selection Jar file export path can be.
Once the export is complete, we can use our own custom control packages just as we would with other jar files. Here's a little demo of how to use this jar package.
Step One:
Create a new folder Lib to put the jar package in.
Step Two:
The associated jar package, as shown in the following illustration:
Step three, use the jar package:
The following code:
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"
xmlns:gif= "http:// Schemas.android.com/apk/res/com.terry.jartest "
android:id=" @+id/layout "android:orientation=" Vertical
" Android:layout_width= "Fill_parent" android:layout_height= "fill_parent" >
<button "Stop" Android:id= "@+id/button01"
android:layout_width= "wrap_content" android:layout_height= "Wrap_content" >< /button>
<button android:text= "Start" android:id= "@+id/button02" android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" ></Button>
<com.terry.gif.typegifview
android:layout_ Width= "Fill_parent" android:id= "@+id/gifview1"
gif:stop= "true" android:layout_height= "Wrap_content
" gif:delay= "1" ></com.terry.gif.TypegifView>
</LinearLayout>
One bad thing is that if you use attributes in your project, you must also copy the attributes to the project you want to use, otherwise you won't be able to identify them.
Thank you for reading, I hope to help you, thank you for your support for this site!