Android Library Project use of summary

1. When the new Android Library Project works or existing works into Android Library Project, if the following statement engineering source code:

 

int id = view.getId();
switch (id) {
case R.id.button1:
action1();
break;
case R.id.button2:
action2();
break;
case R.id.button3:
action3();
        break;
}

Will prompt case expressions must be constant expressions mistake, because after ADT14 Android constant resource library project R.class is not for the final type, reason

See http://tools.android.com/tips/non-constant-fields official explanation. So the above example R.id.button1 not ask constants, can not be used in switch architecture, the simple solution

Is converted to the switch if-else statements, it is very easy to implement in the eclipse, the cursor on the key switch, be installed for press ctrl + 1, FIG press




2. If A ndroid Library Project has Activity, it can no longer manifest file storage project in the statement, but it must be declared in the project to use the library, because the manifest configuration file is independent to the project, can not be reused.


3. If A ndroid Library Project jar used in third-party packages, but also talk about the use of project import the library

Reproduced in: https: //www.cnblogs.com/Codenewbie/p/3374719.html

1. When the new Android Library Project works or existing works into Android Library Project, if the following statement engineering source code:

 

int id = view.getId();
switch (id) {
case R.id.button1:
action1();
break;
case R.id.button2:
action2();
break;
case R.id.button3:
action3();
        break;
}

Will prompt case expressions must be constant expressions mistake, because after ADT14 Android constant resource library project R.class is not for the final type, reason

See http://tools.android.com/tips/non-constant-fields official explanation. So the above example R.id.button1 not ask constants, can not be used in switch architecture, the simple solution

Is converted to the switch if-else statements, it is very easy to implement in the eclipse, the cursor on the key switch, be installed for press ctrl + 1, FIG press




2. If A ndroid Library Project has Activity, it can no longer manifest file storage project in the statement, but it must be declared in the project to use the library, because the manifest configuration file is independent to the project, can not be reused.


3. If A ndroid Library Project jar used in third-party packages, but also talk about the use of project import the library

Guess you like

Origin blog.csdn.net/weixin_34310127/article/details/93448116