2017-10-24 6 views
-1

私はAndroid用の特別な計算アプリケーションをしたいと思いますが、数字が足りない、または大きすぎて計算がうまくいかない場合、私は多くのgoogleingを行いましたが、答えは見つかりませんでした。 これは私の2番目のアプリです。 役立つヒントをいただければ幸いです。計算アプリケーション

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

} 

public void myBerechnen(View v) { 

    EditText Input=(EditText)findViewById(R.id.Input); 

    TextView mal2=(TextView)findViewById(R.id.mal2); 
    TextView mal3=(TextView)findViewById(R.id.mal3); 
    TextView mal4=(TextView)findViewById(R.id.mal4); 
    TextView mal5=(TextView)findViewById(R.id.mal5); 
    TextView mal6=(TextView)findViewById(R.id.mal6); 
    TextView mal7=(TextView)findViewById(R.id.mal7); 
    TextView mal8=(TextView)findViewById(R.id.mal8); 
    TextView mal9=(TextView)findViewById(R.id.mal9); 

    TextView durch2=(TextView)findViewById(R.id.durch2); 
    TextView durch3=(TextView)findViewById(R.id.durch3); 
    TextView durch4=(TextView)findViewById(R.id.durch4); 
    TextView durch5=(TextView)findViewById(R.id.durch5); 
    TextView durch6=(TextView)findViewById(R.id.durch6); 
    TextView durch7=(TextView)findViewById(R.id.durch7); 
    TextView durch8=(TextView)findViewById(R.id.durch8); 
    TextView durch9=(TextView)findViewById(R.id.durch9); 

    Integer Zahl=Integer.parseInt(Input.getText().toString()); 

    mal2.setText(String.valueOf(Zahl * 2)); 
    mal3.setText(String.valueOf(Zahl * 2 * 3)); 
    mal4.setText(String.valueOf(Zahl * 2 * 3 * 4)); 
    mal5.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5)); 
    mal6.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6)); 
    mal7.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7)); 
    mal8.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8)); 
    mal9.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9)); 

    durch2.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2)); 
    durch3.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3)); 
    durch4.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3/4)); 
    durch5.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3/4/5)); 
    durch6.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3/4/5/6)); 
    durch7.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3/4/5/6/7)); 
    durch8.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3/4/5/6/7/8)); 
    durch9.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9/2/3/4/5/6/7/8/9)); 




} 
} 
+0

Integer型で結果を表現できない場合は、代わりにdoubleを使用してみてください – kamiha

+0

何も入れていないのですか? –

+1

@kamihaにもポイントがありますが、クラッシュスタックのトレースも貼り付けてください。私はそこに答えがあると確信しています。 –

答えて

0
mal9.setText(String.valueOf(Zahl * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9)); 

あなたはおそらく整数を格納することができますよりも大きくすることができ、あなたの変数で複数の整数を乗算している文字列にこれを変換しようとしている前に。私はData Typesを読んで、長いか2倍にキャストしようと勧めます。

デバッグしようとすると、特定のエラーコードもありませんか?それはあなたがなぜそれが墜落したのかを正確に伝えるでしょう。