Java 当输入的editText超过10位时,应用程序停止

Java 当输入的editText超过10位时,应用程序停止,java,android,Java,Android,我试图显示calculation textView(txtHasil),它正在运行,但当输入超过10个时,应用程序突然强制关闭。这是我的代码: btnHitung.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //String plafond = NumberTextWatcherForThousand.trimCommaOfS

我试图显示calculation textView(txtHasil),它正在运行,但当输入超过10个时,应用程序突然强制关闭。这是我的代码:

btnHitung.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        //String plafond = NumberTextWatcherForThousand.trimCommaOfString(edtPlafond.getText().toString());
        String plafond = edtPlafond.getText().toString().trim();
        String jasa = edtJasa.getText().toString().trim();

        int edtPlafond = Integer.parseInt(plafond);
        float edtJasa = Float.parseFloat(jasa);

        double hasil = (edtPlafond * edtJasa )/100;


        txtHasil.setText(""+hasil+"\nplafond: "+edtPlafond+"\nJasa: "+edtJasa);
        //txtHasil.addTextChangedListener(new NumberTextWatcherForThousand((EditText) txtHasil));
    }
}
我一直在尝试更改int、float和double。我已经阅读了这个链接:但没有帮助。任何建议都会有帮助。谢谢

Integer.parseInt(plafond);
这就是问题所在。它无法解析任何大于

最好是有一个更长的价值-长

long edtPlafond;
try {

    edtPlafond = Long.parseLong(plafond);

} catch (NumberFormatException e ) {
   e.printStackTrace();
   // add proper error handling
}
以及通过在对话框中显示错误以更好的方式处理错误的示例:

} catch (NumberFormatException e ) {
        new AlertDialog.Builder(getActivity())
          .setTitle("Error: incorrect number entered!")
          .setMessage("The exact error is: " + e.getMessage())
          .setPositiveButton("Ok",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int b) {
                        dialog.cancel();
                    }
                });
          .create()
          .show();
}

注意:所有转换都需要这样的处理…

谢谢,这比强制停止要好。但是需要对catch:use(不使用)进行一些修改{对不起,是从电话中输入的,没有看到两个括号之间的区别…另外,添加了另一个片段,使用长类型,应该能够保存更长的值…这是开玩笑的吗?对于不理解数据类型的人来说,告诉帮助他们的人,他们不知道如何编写错误处理…我的想法是blown@NickCardoso嗯,你说得对……我会纠正这一点,但打电话需要一段时间……@ppeterka我想你误解了我。史蒂文的评论暗示你不理解,我对此感到震惊。这就是为什么我问这是否是开玩笑的意思
} catch (NumberFormatException e ) {
        new AlertDialog.Builder(getActivity())
          .setTitle("Error: incorrect number entered!")
          .setMessage("The exact error is: " + e.getMessage())
          .setPositiveButton("Ok",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int b) {
                        dialog.cancel();
                    }
                });
          .create()
          .show();
}