Original Address:The introduction of resources from another project in Android engineering
87fayuan
You might encounter a problem in a project where a project is too large to be subdivided into N sub-modules, each of which is a different project. When it comes to data transfer, it can be solved by intent and other methods. However, this can be used when it comes to sharing resources, but not as a jar package like a traditional Java program, such as a large number of custom view in the program, and some resource files referenced by these custom view.
Project One: MyViews
The code is as follows:
public class Mytextview extends textview{
Public Mytextview (Context context) {
Super (context);
TODO auto-generated Constructor stub
This.setbackgroundcolor (Color.Blue);
This.settext (Context.getresources (). getString (R.string.test_view));
}
}
On the project one, right button-->properties, check the is Library, OK.
Project two: testactivity
First on the project two, right-click-->properties-->android-->add-->myviews, and then OK
The code is as follows:
public class Testactivity extends Activity {
Private Mytextview MTV;
@Override
Public void OnCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
mtv=new Mytextview (this);
Setcontentview (MTV);
}
}
Operation Engineering Two, can be found to successfully call the project Mytextview
[Reprint]android project in the introduction of resources in another project