I would like to integrate zxing into my app. I'm importing project, set it as library, change target to API 7, download zxing-core-2.2.jar, copy it to /libs and add this jar in Java Building Path as library.
But there are still some errors:
All of them are in switch statements and depend on R.id. for example:
switch (item.getItemId()) {
case R.id.menu_share:
Eclipse error description:
case expressions must be constant expressions
there is a info dialog:
Any idea what I'm doing wrong or how to fix it?
As explained in the dialog you have shown, R.id.menu_settings is now "no longer constant", which means it cannot be used in a switch. the dialog also provides the solution, instead of
switch (item.getItemId()) {
case R.id.menu_share:
//do something
break;
case xxx:
...
}
You should do this:
if(item.getItemId()==R.id.menu_share) {
//do something
} else if (item.getItemId()==xxx) {
//do something
}
Just follow the instruction and you should be fine.