2011-07-20 19 views
0

我在運行時得到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 
       } 
     }); 
+0

你能正確地格式化你的問題,其難以閱讀...... – Marty

+0

你可以把你的logcat錯誤 – Rasel

+0

顯示com.androidbook.triviaquiz8/.QuizHelpActivity:+ 656ms 關閉虛擬機 threadid = 1:線程退出與未捕獲的異常(組= 0x40015560) 發送信號。 PID:22123 SIG:9 – WmBurkert

回答

0

編譯似乎只能驗證代碼,但沒有邏輯的一個需求,你不能比較的字符串要非常小心的代碼,我現在推薦大量的意見和嚴格的格式與凹痕,所以如果語句很容易確定開始和結束FC當程序留下決定它不能讓

1

與== operator.Use的equals()方法來compare.Try這樣

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 
+0

男士我感謝你。我會成爲一名好學生,需要找一個班! – WmBurkert

+0

做了更改,我瞭解新的邏輯,但事情繼續FC,所以我不瞭解調試。 java的東西現在看起來都是正確的,我昨晚有方塊工作,但還沒有評估形狀微調。我知道我最終會得到這個障礙,學習調試。這整個處理是一直正常的冒險學習,我準備好很快開始問真的很好的問題:) – WmBurkert

+0

更改後顯示您的所有代碼 – Rasel

相關問題