2017-04-10 69 views
-3

我想製作一個科學計算器(Android應用程序),但會出現一些問題。我不知道Java,但我瞭解代碼,因爲我知道C++。 我已經修改了一個普通的計算器的代碼到一個科學計算器,但代碼似乎並沒有工作。 只有基本功能,如+-*/工作,但我喜歡加SinCosTanSqrtPowExp等功能似乎並不當我使用這些功能的應用程序崩潰的工作。 這是我的源代碼。我的Android應用程序不斷崩潰

MainActivity.java

package com.example.anant.scientificcalculator; 

import android.databinding.DataBindingUtil; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import static java.lang.Math.*; 
import java.text.DecimalFormat; 
import com.example.anant.scientificcalculator.databinding.MainActivityBinding; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView; 

public class MainActivity extends AppCompatActivity { 

private MainActivityBinding binding; 

private static final char FACT = '!'; 
private static final char POWER = '^'; 
private static final String SQRT = "SQRT"; 

private static final String SIN = "SIN"; 
private static final String COS = "COS"; 
private static final String TAN = "TAN"; 
private static final String LOG = "LOG"; 

private static final char LEFTC = '('; 
private static final char RIGHTC = ')'; 
private static final String EXP = "EXP"; 
private static final String PIE = "PIE"; 

private static final char ADD = '+'; 
private static final char SUBTRACT = '-'; 
private static final char MULTIPlY = '*'; 
private static final char DIVIDE = '/'; 

private char CURRENT_ACTION; 
private String ADVANCE_ACTION; 

private double valueOne = Double.NaN; 
private double valueTwo; 
private double valueTemp; 

private DecimalFormat decimalFormat; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    decimalFormat = new DecimalFormat("#.##########"); 

    binding = DataBindingUtil.setContentView(this, R.layout.main_activity); 

    binding.buttonDot.setOnClickListener(new View.OnClickListener(){ 
     @Override 
       public void onClick(View view){ 
        binding.editText.setText(binding.editText.getText() + "."); 
     } 
    }); 

    binding.buttonZero.setOnClickListener(new View.OnClickListener(){ 
     @Override 
      public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "0"); 
     } 
    }); 

    binding.buttonOne.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "1"); 
     } 
    }); 

    binding.buttonTwo.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "2"); 
     } 
    }); 

    binding.buttonThree.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "3"); 
     } 
    }); 

    binding.buttonFour.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "4"); 
     } 
    }); 

    binding.buttonFive.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "5"); 
     } 
    }); 

    binding.buttonSix.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "6"); 
     } 
    }); 

    binding.buttonSeven.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "7"); 
     } 
    }); 

    binding.buttonEight.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "8"); 
     } 
    }); 

    binding.buttonNine.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "9"); 
     } 
    }); 

    binding.buttonLeftC.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + "("); 
     } 
    }); 

    binding.buttonRightC.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      binding.editText.setText(binding.editText.getText() + ")"); 
     } 
    }); 

    binding.buttonExp.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      computeCalculation(); 
      ADVANCE_ACTION = EXP; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "EXP"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonPie.setOnClickListener(new View.OnClickListener(){ 
     @Override 
     public void onClick(View view){ 
      computeCalculation(); 
      ADVANCE_ACTION = PIE; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "PIE"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonAdd.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      CURRENT_ACTION = ADD; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "+"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonSubtract.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      CURRENT_ACTION = SUBTRACT; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "-"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonMultiply.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      CURRENT_ACTION = MULTIPlY; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "*"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonDivide.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      CURRENT_ACTION = DIVIDE; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "/"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonFact.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      CURRENT_ACTION = FACT; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "!"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonPow.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      CURRENT_ACTION = POWER; 
      binding.infoTextView.setText(decimalFormat.format(valueOne) + "^"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonSqrt.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      ADVANCE_ACTION = SQRT; 
      binding.infoTextView.setText("SQRT(" + decimalFormat.format(valueOne) + ")"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonSine.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      ADVANCE_ACTION = SIN; 
      binding.infoTextView.setText("SIN(" + decimalFormat.format(valueOne) + ")"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonCosine.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      ADVANCE_ACTION = COS; 
      binding.infoTextView.setText("COS(" + decimalFormat.format(valueOne) + ")"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonTangent.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      ADVANCE_ACTION = TAN; 
      binding.infoTextView.setText("TAN(" + decimalFormat.format(valueOne) + ")"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonLog.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      ADVANCE_ACTION = LOG; 
      binding.infoTextView.setText("LOG(" + decimalFormat.format(valueOne) + ")"); 
      binding.editText.setText(null); 
     } 
    }); 

    binding.buttonEqual.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      computeCalculation(); 
      binding.infoTextView.setText(binding.infoTextView.getText().toString() + 
        decimalFormat.format(valueTwo) + " = " + decimalFormat.format(valueOne)); 
      valueOne = Double.NaN; 
      CURRENT_ACTION = '0'; 
     } 
    }); 

    binding.buttonClear.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      if(binding.editText.getText().length() > 0) { 
       CharSequence currentText = binding.editText.getText(); 
       binding.editText.setText(currentText.subSequence(0, currentText.length()-1)); 
      } 
      else { 
       valueOne = Double.NaN; 
       valueTwo = Double.NaN; 
       binding.editText.setText(""); 
       binding.infoTextView.setText(""); 
      } 
     } 
    }); 

} 

private void computeCalculation() { 
    if(!Double.isNaN(valueOne)) { 
     valueTwo = Double.parseDouble(binding.editText.getText().toString()); 
     binding.editText.setText(null); 

     if(CURRENT_ACTION == ADD) 
      valueOne = this.valueOne + valueTwo; 
     else if(CURRENT_ACTION == SUBTRACT) 
      valueOne = this.valueOne - valueTwo; 
     else if(CURRENT_ACTION == MULTIPlY) 
      valueOne = this.valueOne * valueTwo; 
     else if(CURRENT_ACTION == DIVIDE) 
      valueOne = this.valueOne/valueTwo; 
     else if(CURRENT_ACTION == FACT) 
     { 
      valueTemp = this.valueOne; 
      int i,valueThree=1; 

      for(i=(int) valueTemp;i>0;i--) //type conversion 
      { 
       valueThree *= i; 
      } 
      valueOne = valueThree; 
     } 
     else if(CURRENT_ACTION == POWER) { 
      valueTemp = this.valueOne; 
      valueTemp = Math.pow(valueOne, valueTwo); 
      valueOne = valueTemp; 
     } 
     else if(ADVANCE_ACTION == SQRT) { 
      valueTemp = this.valueOne; 
      valueOne = Math.sqrt(valueTemp); 
     } 
     else if(ADVANCE_ACTION == SIN) { 
      valueTemp = this.valueOne; 
      valueOne = Math.sin(valueTemp); 
     } 
     else if(ADVANCE_ACTION == COS) { 
      valueTemp = this.valueOne; 
      valueOne = Math.cos(valueTemp); 
     } 
     else if(ADVANCE_ACTION == TAN) { 
      valueTemp = this.valueOne; 
      valueOne = Math.tan(valueTemp); 
     } 
     else if(ADVANCE_ACTION == LOG) { 
      valueTemp = this.valueOne; 
      valueOne = Math.log(valueTemp); 
     } 
     else if(ADVANCE_ACTION == PIE) { 
      valueTemp = this.valueOne; 
      valueTemp = Math.PI; 
      valueOne = valueTemp; 
     } 
     else if(ADVANCE_ACTION == EXP) { 
      valueTemp = this.valueOne; 
      valueTemp = Math.E; 
      valueOne = valueTemp; 
     } 
    } 
    else { 
     try { 
      valueOne = Double.parseDouble(binding.editText.getText().toString()); 
     } 
     catch (Exception e){} 
    } 
} 
} 

誰能告訴我爲什麼我的應用程序不斷崩潰?

main_activity.xml

<?xml version="1.0" encoding="utf-8"?> 
<layout> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/main_activity" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.anant.scientificcalculator.MainActivity"> 


<TextView 
    android:id="@+id/infoTextView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="30dp" 
    android:textSize="30sp" /> 

<EditText 
    android:id="@+id/editText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/infoTextView" 
    android:enabled="false" 
    android:gravity="bottom" 
    android:hint="0" 
    android:inputType="numberDecimal" 
    android:lines="2" 
    android:maxLines="2" 
    android:textAlignment="textEnd" 
    android:textColor="@android:color/black" 
    android:textSize="40sp" /> 

<Button 
    android:id="@+id/buttonFact" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/editText" 
    android:text="@string/buttonFact" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonPow" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/editText" 
    android:layout_toRightOf="@id/buttonFact" 
    android:text="@string/buttonPow" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonSqrt" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/editText" 
    android:layout_toRightOf="@id/buttonPow" 
    android:text="@string/buttonSqrt" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonClear" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/buttonSqrt" 
    android:layout_below="@id/editText" 
    android:text="@string/buttonClear" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonSine" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonFact" 
    android:text="@string/buttonSine" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonCosine" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonPow" 
    android:layout_toRightOf="@id/buttonSine" 
    android:text="@string/buttonCosine" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonTangent" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonSqrt" 
    android:layout_toRightOf="@id/buttonCosine" 
    android:text="@string/buttonTangent" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonLog" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonClear" 
    android:layout_toRightOf="@id/buttonTangent" 
    android:text="@string/buttonLog" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonLeftC" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonSine" 
    android:text="@string/buttonLeftC" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonRightC" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonCosine" 
    android:layout_toRightOf="@id/buttonLeftC" 
    android:text="@string/buttonRightC" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonExp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonTangent" 
    android:layout_toRightOf="@id/buttonRightC" 
    android:text="@string/buttonExp" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonPie" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonLog" 
    android:layout_toRightOf="@id/buttonExp" 
    android:text="@string/buttonPie" 
    android:textSize="20sp" /> 


<Button 
    android:id="@+id/buttonSeven" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonLeftC" 
    android:text="@string/buttonSeven" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonEight" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonRightC" 
    android:layout_toRightOf="@id/buttonSeven" 
    android:text="@string/buttonEight" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonNine" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonExp" 
    android:layout_toRightOf="@id/buttonEight" 
    android:text="@string/buttonNine" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonFour" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonSeven" 
    android:text="@string/buttonFour" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonFive" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonEight" 
    android:layout_toRightOf="@id/buttonFour" 
    android:text="@string/buttonFive" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonSix" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonNine" 
    android:layout_toRightOf="@id/buttonFive" 
    android:text="@string/buttonSix" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonOne" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonFour" 
    android:text="@string/buttonOne" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonTwo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonFive" 
    android:layout_toRightOf="@id/buttonOne" 
    android:text="@string/buttonTwo" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonThree" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonSix" 
    android:layout_toRightOf="@id/buttonTwo" 
    android:text="@string/buttonThree" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonDot" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonOne" 
    android:text="@string/buttonDot" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonZero" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/buttonTwo" 
    android:layout_toRightOf="@id/buttonDot" 
    android:text="@string/buttonZero" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonEqual" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignRight="@id/buttonNine" 
    android:layout_below="@id/buttonThree" 
    android:text="@string/buttonEqual" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonDivide" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@id/buttonNine" 
    android:layout_toRightOf="@id/buttonNine" 
    android:text="@string/buttonDIvide" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonMultiply" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@id/buttonSix" 
    android:layout_toRightOf="@id/buttonSix" 
    android:text="@string/buttonMultiply" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonSubtract" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@id/buttonThree" 
    android:layout_toRightOf="@id/buttonThree" 
    android:text="@string/buttonSubtract" 
    android:textSize="20sp" /> 

<Button 
    android:id="@+id/buttonAdd" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@id/buttonEqual" 
    android:layout_toRightOf="@id/buttonEqual" 
    android:text="@string/buttonAdd" 
    android:textSize="20sp" /> 

</RelativeLayout> 
</layout> 
+4

發佈您的logcat錯誤msg – sravs

+0

你是什麼意思 –

+0

請錯誤日誌? – Aryan

回答

1

我設法與小的改動運行代碼。

這個問題似乎是在這裏:

private void computeCalculation() { 
     if(!Double.isNaN(valueOne)) { 
      valueTwo = Double.parseDouble(binding.editText.getText().toString()); 
      binding.editText.setText(null); 

如果撞車後檢查向下跌破了Android監視器,你會看到這樣的事情:

04-10 13:01:01.531 20742-20742/com.johnurrutia.so_43315233 E/AndroidRuntime: FATAL EXCEPTION: main 
                       Process: com.johnurrutia.so_43315233, PID: 20742 
                       java.lang.NumberFormatException: Invalid double: "" 
                        at java.lang.StringToReal.invalidReal(StringToReal.java:63) 
                        at java.lang.StringToReal.parseDouble(StringToReal.java:267) 
                        at java.lang.Double.parseDouble(Double.java:301) 
                        at com.johnurrutia.so_43315233.MainActivity.computeCalculation(MainActivity.java:303) 
                        at com.johnurrutia.so_43315233.MainActivity.access$100(MainActivity.java:11) 
... 

它會告訴你有一個致命異常由於一個ivalid double。您可以在303行中跟蹤MainActivity.java(最有可能有不同的行)。

使用該行上的調試器,您可以檢查並查看發生了什麼。

我認爲你試圖將一個空字符串轉換爲雙精度。

我爲運行您的代碼所做的更改如下。

1)在佈局文件中: a)使用android名稱空間更改佈局標記。 二)新增了一個空的佔位符(不知道它的必要與否)

<?xml version="1.0" encoding="utf-8"?> 
<layout xmlns:android="http://schemas.android.com/apk/res/android"> 
    <data> 

    </data> 
    <RelativeLayout 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/main_activity" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context="com.johnurrutia.so_43315233.MainActivity"> 

... 
</layout> 

c)在EditText上存在,這似乎是不符合所選擇的重力所以「ENDTEXT」對準我只是擦除它。 d)由於您尚未發佈,請確保您的res/values/string.xml文件中包含所有@ string/stringname設置。

2)當您使用數據綁定時,請檢查您的Gradle應用程序模塊文件。你必須有:

android { 

    ... 

    dataBinding { 
     enabled = true 
    } 
} 

3)之後,看看你的文件,並檢查你什麼都看不到紅色。

4)點擊Build-> Clean Project。然後運行。

+0

爲什麼downvote?我只是向您展示Android中大部分活動的工作方式。他們肯定不會給出編譯錯誤。 – Juan

+0

我沒有給出反對 –

+0

應用程序仍然崩潰 –

0

,你需要這樣的解決您的問題..

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main_activity); 
    } 
+0

請讓我知道downvote原因.... –

+0

應用仍然會崩潰 –

+0

我沒有給一個向下票 –