我试图在我的底部菜单上获得4个项目,但第4个项目不是动画,如果我切换到完全不同的菜单格式,我认为此菜单类型将支持3-5个项目。 / p>
public static void main(String[] args) {
boolean loop = true;
while (loop == true){
commands();
System.out.println("Please enter what you would like to do: (+,-,*,/,%)");
String function = input.nextLine();
System.out.println("Enter the first number to be calucalted (If dividing, this is the numerator):");
double n1 = input.nextDouble();
input.nextLine();
System.out.println("Enter the second number to be calucalted (If dividing, this is the denominator):");
double n2 = input.nextDouble();
input.nextLine();
//=======================
// Addition
//=======================
if (function.equals("+")){
double sum = n1+n2;
System.out.println(n1+"+"+ n2 +" = " + sum);
System.out.println("e = end | c = clear | m = save | r = recall");
String command = input.nextLine();
switch (command){
case "e":
end();
break;
case "c":
clear();
break;
case "m":
save(sum);
break;
case "r":
recall();
break;
}
}
主要活动代码
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:icon="@mipmap/news_icon"
android:title="@string/title_news" />
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_dashboard_black_24dp"
android:title="@string/title_schedule" />
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_team" />
<item
android:id="@+id/login"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_team" />
</menu>
答案 0 :(得分:0)
我犯了一个愚蠢的错误,结果我在onNavigationItemSelected函数中没有为switch语句返回true。