Java 如果使用微调器,则显示值

Java 如果使用微调器,则显示值,java,android,Java,Android,我在运行时得到FC,但它可以编译 注:在Rasel的评论之后进行了更改。还是FC的 btnExecute.setOnClickListener(new View.OnClickListener() //this worked { private AlertDialog show; public void onClick(View arg0) { //start

我在运行时得到FC,但它可以编译

注:在Rasel的评论之后进行了更改。还是FC的

                        btnExecute.setOnClickListener(new View.OnClickListener() //this worked
        {
            private AlertDialog show;
            public void onClick(View arg0) 
            { //start of get stack shape and provide area and equivalent diameter
              //20110720
              //just trying to evaluate the shape to use the correct inputs for area calculation
              //I will then add and evaluate for the units of input to build universal
              //values(_eng and _met)variables to use for all further calculations. KISS!

                if (((m1_ss_spinner.getSelectedItem().toString().equals("Square")))) //cant compare a string with == operator.  Use equals() to compare
                {
                    if ((m1_sqs1.getText().length() == 0)              //if m1_sqs1 is empty
                        || (m1_sqs1.getText().toString().equals("")))  //if m1_sqs1 is blank
                    {           
                            show = new AlertDialog.Builder(mContext).setTitle("Error") //this worked
                                .setMessage("The Square Side length is empty")               
                                .setPositiveButton("OK", null).show();          
                    } else
                        {
                            double result = new Double(m1_sqs1.getText().toString()) * new Double(m1_sqs1.getText().toString());   
                            m1_sa_in.setText(Double.toString(result));
                        } //end of square area
                } else      

                    if (((m1_ss_spinner.getSelectedItem().toString().equals("Rectangle"))))
                    {
                        if ((m1_rs1.getText().length() == 0)
                            || (m1_rs1.getText().toString().equals("")
                            || (m1_rs2.getText().length() == 0)
                            || (m1_rs2.getText().toString().equals(""))))
                        {
                                show = new AlertDialog.Builder(mContext).setTitle("Error")
                                .setMessage("A Rectangle Side length is empty")               
                                .setPositiveButton("OK", null).show();
                        } else 
                            {
                                double result = new Double(m1_rs1.getText().toString()) * new Double(m1_rs2.getText().toString());   
                                m1_sa_in.setText(Double.toString(result));
                            } //end of rectangle area
                } else

                    if (((m1_ss_spinner.getSelectedItem().toString().equals("Circle"))))
                    {
                        if ((m1_cd.getText().length() == 0)            
                            || (m1_cd.getText().toString().equals("")))
                        {
                                show = new AlertDialog.Builder(mContext).setTitle("Error")
                                .setMessage("The Circle Diameter is empty")               
                                .setPositiveButton("OK", null).show();
                        } else 
                            {
                                double result = new Double(m1_cd.getText().toString()) * new Double(m1_cd.getText().toString());   
                                m1_sa_in.setText(Double.toString(result));
                            } //end of circle area
                } else

                        if (((m1_ss_spinner.getSelectedItem().toString().equals("Elliptical")))) 
                        {
                            if ((m1_els1.getText().length() == 0)           
                            || (m1_els1.getText().toString().equals("")
                            || (m1_els2.getText().length() == 0)
                            || (m1_els2.getText().toString().equals(""))))
                            {
                                show = new AlertDialog.Builder(mContext).setTitle("Error")
                                .setMessage("An Elliptical Diameter is empty")               
                                .setPositiveButton("OK", null).show();
                        } else 
                            {
                                double result = new Double(m1_els1.getText().toString()) * new Double(m1_els2.getText().toString());   
                                m1_sa_in.setText(Double.toString(result));
                            }; //end of elliptical area
                    } // end of onClick code
                }
        });

不能将字符串与==运算符进行比较。请使用equals()方法进行比较。请像这样尝试

 if (((m1_ss_spinner.getSelectedItem().toString().equals("Square")))) //need to prove this

                    {

                        if ((m1_sqs1.getText().length() == 0)           //if m1_sqs1 is empty
                            || (m1_sqs1.getText().toString().equals("")))   //if m1_sqs1 is blank

编译似乎只是验证代码,而不是验证逻辑一个人需要非常小心地使用代码,我现在建议使用大量注释和带有缩进的严格格式,这样,如果语句很容易确定开始和结束FCs,那么当程序没有做出决定时,它就会出现。

谢谢。我会是一个好学生,需要找一个班!做了这些改变,我理解了新的逻辑,但事情还在继续,所以我要去学习调试。java的东西现在看起来都是正确的,我昨天晚上让方形部件工作,但还没有评估形状微调器。我知道我最终会克服这个障碍,学会调试。这整个过程是学习的正常过程,我准备很快开始问一些非常好的问题:)评论部分太小,格式太疯狂。我是否启动了一个新线程?你能正确设置你的问题的格式吗?很难阅读…你能把你的logcat errorDisplayed com.androidbook.triviaquiz8/.QuizhelActivity:+656ms关闭VM threadid=1:线程退出,但未捕获异常(组=0x40015560)发送信号吗。PID:22123 SIG:9评论完对话框后,我不知道这是什么意思。