I have been told I must change my switch statements to If-Else statements due to changes in API 14.
由于API 14的变化,我被告知必须将我的switch语句更改为If-Else语句。
Thats fine.
这很好。
What isn't working is when I place my caret over the switch statement and press CTRL-1 as per the instructions I am given no options, I am using Ubuntu by the way, any suggestions?
当我把我的插入符号放在switch语句上,按下CTRL-1按我没有选择的指令按CTRL-1时,我正在使用Ubuntu,有什么建议吗?
I've also tried cleaning my project.
我也尝试过清理我的项目。
edit. Its working for all other switch statements just not the one contained here:
编辑。它适用于所有其他的交换机声明而不是这里所包含的:
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnCalcCalories:
double weight = Integer.parseInt(etWeight.getText().toString());
double bodyfat = Integer.parseInt(etBodyfat.getText().toString());
;
lbm = weight * (100 - bodyfat) / 100;
bmr = 370 + (21.6 * lbm);
maintCals = bmr * actLevel;
maintCalories
.setText("Calories need to maintain current bodyweight: "
+ String.valueOf(maintCals));
lbmResult.setText("Your Lean Body Mass is " + String.valueOf(lbm)
+ "Kg");
bmrResult.setText("Your Base Metabolic rate is "
+ String.valueOf(bmr) + " calories");
calorieResult.setText("Your Daily calorie goal is "
+ String.valueOf(finalGPercentage) + " calories");
break;
case R.id.btnUpdateDB:
boolean worked = true;
try {
String dbWeight = curWeight.getText().toString();
String dbWaist = curWaist.getText().toString();
String dbChest = curChest.getText().toString();
String dbLegs = curLegs.getText().toString();
String dbArms = curArms.getText().toString();
Stats entry = new Stats(MainActivity.this);
entry.open();
entry.createEntry(dbWeight, dbWaist, dbChest, dbArms, dbLegs);
entry.close();
break;
} catch (Exception e) {
worked = false;
String error = e.toString();
Dialog d = new Dialog(this);
d.setTitle("Error");
TextView tv = new TextView(this);
tv.setText(error);
d.setContentView(tv);
d.show();
} finally {
if (worked) {
Dialog d = new Dialog(this);
d.setTitle("DB Worked");
TextView tv = new TextView(this);
tv.setText("Success");
d.setContentView(tv);
d.show();
}
}
case R.id.btnViewDB:
Intent i = new Intent("com.uhi.fatfighter.DBView");
startActivity(i);
break;
case R.id.btnStopwatchActivity:
Intent s = new Intent("com.uhi.fatfighter.Stopwatch");
startActivity(s);
break;
case R.id.btnMapARun:
Intent m = new Intent("com.uhi.fatfighter.MapRun");
startActivity(m);
break;
case R.id.btnWeightConverter:
Intent w = new Intent("com.uhi.fatfighter.WeightConverter");
startActivity(w);
break;
}
}
2 个解决方案
#1
4
In my project properties I had my Google-libs checked as 'is library', unchecked this and it fixed the problem.
在我的项目属性中,我检查了我的Google-libs作为'is library',不检查这个,它就解决了问题。
#2
0
-
The problem is that Eclipse is stupid. You should use IntelliJ IDEA if you want do cool stuff like this.
问题是Eclipse是愚蠢的。如果你想做一些很酷的事情,你应该使用IntelliJ创意。
-
Don't forget to call trim() method to remove trailing spaces.
不要忘记调用trim()方法来删除尾随空格。
double weight = Integer.parseInt(etWeight.getText().toString());
.toString双重量= Integer.parseInt(etWeight.getText()());
-
Using magic numbers is not good manner.
使用魔术数字不是好的方式。
bmr = 370 + (21.6 x lbm);
bmr = 370 + (21.6 x lbm);
-
Catching root Exception is not good manner.
捕获根异常不是好方法。
catch (Exception e)
捕获(异常e)
-
Never show Dialog in finally block, your application may crash at this time.
不要在finally块中显示对话框,您的应用程序此时可能会崩溃。
#1
4
In my project properties I had my Google-libs checked as 'is library', unchecked this and it fixed the problem.
在我的项目属性中,我检查了我的Google-libs作为'is library',不检查这个,它就解决了问题。
#2
0
-
The problem is that Eclipse is stupid. You should use IntelliJ IDEA if you want do cool stuff like this.
问题是Eclipse是愚蠢的。如果你想做一些很酷的事情,你应该使用IntelliJ创意。
-
Don't forget to call trim() method to remove trailing spaces.
不要忘记调用trim()方法来删除尾随空格。
double weight = Integer.parseInt(etWeight.getText().toString());
.toString双重量= Integer.parseInt(etWeight.getText()());
-
Using magic numbers is not good manner.
使用魔术数字不是好的方式。
bmr = 370 + (21.6 x lbm);
bmr = 370 + (21.6 x lbm);
-
Catching root Exception is not good manner.
捕获根异常不是好方法。
catch (Exception e)
捕获(异常e)
-
Never show Dialog in finally block, your application may crash at this time.
不要在finally块中显示对话框,您的应用程序此时可能会崩溃。