AlertDialog在显示双格式值时崩溃(Android)

AlertDialog在显示双格式值时崩溃(Android),android,mobile,crash,Android,Mobile,Crash,因此,当我模拟安卓2.3.3时,一切正常,并显示格式化的值。但是,当我发送到手机时,手机会崩溃,应用程序也会关闭。当我删除格式化的双重数据时,它在我的手机上工作 那会是什么 谢谢 代码如下: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.editPro

因此,当我模拟安卓2.3.3时,一切正常,并显示格式化的值。但是,当我发送到手机时,手机会崩溃,应用程序也会关闭。当我删除格式化的双重数据时,它在我的手机上工作

那会是什么

谢谢

代码如下:

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

    this.editProductValue = (EditText)findViewById(R.id.productValue);
    this.editProductShipping = (EditText)findViewById(R.id.productShipping);
    this.cbCCFlagNames = (Spinner)findViewById(R.id.cbCCFlag);
    this.cbCCInstallments = (Spinner)findViewById(R.id.cbInstallment);
    this.btnCalc = (Button)findViewById(R.id.btnCalc);

    this.cbCCFlagNames.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            cbCCInstallments.setSelection(Adapter.NO_SELECTION);
            String ccName = parent.getItemAtPosition(pos).toString();
            Vector<String> lstInstallments = new Vector<String>();

            if(ccName.matches("America Express")) {
                for(int count = 1; count <= 15; count ++) {
                    if(count == 1 || count % 3 == 0) {
                        lstInstallments.add(Integer.toString(count));
                    }
                }
            } else if(ccName.matches("Cartão Mercado Livre")) {
                for(int count = 1; count <= 24; count ++) {
                    if(count == 1 || count % 3 == 0 && count != 21) {
                        lstInstallments.add(Integer.toString(count));
                    }
                }
            } else {
                for(int count = 1; count <= 12; count ++) {
                    if(count == 1 || count % 3 == 0) {
                        lstInstallments.add(Integer.toString(count));
                    }
                }
            }

            String[] strList = lstInstallments.toArray(new String[lstInstallments.size()]);
            ArrayAdapter<String> newList = new ArrayAdapter<String>(Main.this, android.R.layout.simple_list_item_1, strList);
            cbCCInstallments.setAdapter(newList);
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            return;             
        }

    });


    this.btnCalc.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {


            if(editProductValue.getText().toString().matches("") || editProductShipping.getText().toString().matches("")) {
                Toast.makeText(Main.this, "Por favor, preencha todos os campos!",Toast.LENGTH_LONG).show();
            } else {
                double value = Double.parseDouble(editProductValue.getText().toString());
                double shipp = Double.parseDouble(editProductShipping.getText().toString());
                int parcel = Integer.parseInt(cbCCInstallments.getSelectedItem().toString());
                DecimalFormat twoDForm = new DecimalFormat("#.##");
                double total = 0;

                switch(parcel) {
                case 1:
                    total = (value + shipp + ((value + shipp) * 0)) / parcel;
                    break;

                case 3:
                    total = (value + shipp + ((value + shipp) * 0.0699)) / parcel;
                    break;

                case 6:
                    total = (value + shipp + ((value + shipp) * 0.1199)) / parcel;
                    break;

                case 9:
                    total = (value + shipp + ((value + shipp) * 0.1449)) / parcel;
                    break;

                case 12:
                    total = (value + shipp + ((value + shipp) * 0.1599)) / parcel;
                    break;

                case 15:
                    total = (value + shipp + ((value + shipp) * 0.1849)) / parcel;
                    break;

                case 18:
                    total = (value + shipp + ((value + shipp) * 0.2149)) / parcel;
                    break;

                case 24:
                    total = (value + shipp + ((value + shipp) * 0.2799)) / parcel;
                    break;
                }

                total = Double.valueOf(twoDForm.format(total));
                double totalParcel = Double.valueOf(twoDForm.format(total * parcel));
                String message = "Parcelas: " + parcel 
                        + "x\nValor das Parcelas: R$" + total
                        + "\nTotal a Prazo: R$" + totalParcel
                        + "\n\nOBS.: As taxas de juros estão sujeitas a mudanças de acordo com o Mercado Livre.";

                AlertDialog.Builder result = new AlertDialog.Builder(Main.this);
                result.setTitle("Total Parcelado");
                result.setMessage(message);
                result.setNeutralButton("Fechar", null);
                result.show();
            }
        }

    });

发布日志猫,它使人们更容易帮助您找到错误。但它不会生成日志猫。。。在emulator中,它可以正常工作,但在我的手机/平板电脑中却无法正常工作!它只是说应用程序已停止并关闭。使用Android的
Log
类在整个应用程序中放置日志,以便您可以看到它进入了什么位置以及它在哪里停止工作。在您的手机/平板电脑上安装时,请将电线与计算机保持连接,它应在logcat输出中生成日志window@AndroidStudent谢谢你,伙计!现在我有了一只logcat!英雄联盟
05-15 16:54:14.439: E/AndroidRuntime(28844): FATAL EXCEPTION: main
05-15 16:54:14.439: E/AndroidRuntime(28844): java.lang.NumberFormatException
05-15 16:54:14.439: E/AndroidRuntime(28844):    at org.apache.harmony.luni.util.FloatingPointParser.parseDblImpl(Native Method)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:283)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at java.lang.Double.parseDouble(Double.java:318)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at java.lang.Double.valueOf(Double.java:356)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at br.com.grindsoft.calcjurml.Main$2.onClick(Main.java:127)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at android.view.View.performClick(View.java:2485)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at android.view.View$PerformClick.run(View.java:9080)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at android.os.Handler.handleCallback(Handler.java:587)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at android.os.Looper.loop(Looper.java:123)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at android.app.ActivityThread.main(ActivityThread.java:3729)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at java.lang.reflect.Method.invokeNative(Native Method)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at java.lang.reflect.Method.invoke(Method.java:507)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
05-15 16:54:14.439: E/AndroidRuntime(28844):    at dalvik.system.NativeStart.main(Native Method)