[Reprint]android project in the introduction of resources in another project

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.