In the project encountered such exception: caseexpressions must is constant expressions
public class Standingcityactivity extends Activity implements view.onclicklistener{}
@Override public void OnClick (View v) { switch (V.getid ()) { r.id.back: Break ; Default: Break ; } }
From the syntax, logic above, there is no problem, but eclipse error ~ ~ ~
Baidu on the Internet to find solutions, the vast number of programmers comrades to provide a solution
http://blog.csdn.net/aaawqqq/article/details/20037407
The main reason is that the current project is a result of the library being referenced by other projects.
Feeling a little puzzled, estimating the relationship with Eclipse support? Or whatever it is, it's not.
One solution is to remove the option from the IS library in the project configuration in eclipse
Another workaround is to set listener for each control individually:
Back.setonclicklistener (New View.onclicklistener () { @Override public void OnClick (View v) { //TODO auto-generated method Stub } });
Add:
When the current project is set to the library, all switch is not available.
Android switch statement case expressions must is constant expressions