Java 计算应用程序

Java 计算应用程序,java,android,calculator,Java,Android,Calculator,我想为Android做一个特殊的计算应用程序,但如果我没有或太高的数字,然后按calculate,它就会崩溃,我在谷歌上搜索了很多次,但没有找到答案。 这是我的第二个应用程序。 任何有用的提示都将不胜感激 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

我想为Android做一个特殊的计算应用程序,但如果我没有或太高的数字,然后按calculate,它就会崩溃,我在谷歌上搜索了很多次,但没有找到答案。 这是我的第二个应用程序。 任何有用的提示都将不胜感激

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

public void myBerechnen(View v) {

    EditText Input=(EditText)findViewById(R.id.Input);

    TextView mal2=(TextView)findViewById(R.id.mal2);
    TextView mal3=(TextView)findViewById(R.id.mal3);
    TextView mal4=(TextView)findViewById(R.id.mal4);
    TextView mal5=(TextView)findViewById(R.id.mal5);
    TextView mal6=(TextView)findViewById(R.id.mal6);
    TextView mal7=(TextView)findViewById(R.id.mal7);
    TextView mal8=(TextView)findViewById(R.id.mal8);
    TextView mal9=(TextView)findViewById(R.id.mal9);

    TextView durch2=(TextView)findViewById(R.id.durch2);
    TextView durch3=(TextView)findViewById(R.id.durch3);
    TextView durch4=(TextView)findViewById(R.id.durch4);
    TextView durch5=(TextView)findViewById(R.id.durch5);
    TextView durch6=(TextView)findViewById(R.id.durch6);
    TextView durch7=(TextView)findViewById(R.id.durch7);
    TextView durch8=(TextView)findViewById(R.id.durch8);
    TextView durch9=(TextView)findViewById(R.id.durch9);

    Integer Zahl=Integer.parseInt(Input.getText().toString());

    mal2.setText(String.valueOf(Zahl * 2));
    mal3.setText(String.valueOf(Zahl * 2 * 3));
    mal4.setText(String.valueOf(Zahl * 2 * 3 * 4));
    mal5.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5));
    mal6.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6));
    mal7.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7));
    mal8.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8));
    mal9.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9));

    durch2.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2));
    durch3.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3));
    durch4.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3 / 4));
    durch5.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3 / 4 / 5));
    durch6.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3 / 4 / 5 / 6));
    durch7.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3 / 4 / 5 / 6 / 7));
    durch8.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3 / 4 / 5 / 6 / 7 / 8));
    durch9.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9));




}
}
在您尝试将其转换为字符串之前,您需要将多个整数与变量相乘,该变量可能大于整数所能存储的值。我建议你读一读,然后试着把它转换成长的或者双的


当您尝试调试它时,是否也没有特定的错误代码?这会告诉你它崩溃的确切原因。

也许你不能用整型来表示结果,试着用double代替。你没有输入数字,它崩溃了吗?@kamiha有一点,也请粘贴崩溃堆栈跟踪。我肯定有答案。
mal9.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9));