我想爲老師(我的媽媽)提供一個應用程序來計算等級字母和一定數量的可能數量錯誤的百分比。按下第一個屏幕上的按鈕後,應用程序崩潰。我想知道是否有人可以幫助我。不適用於Android Studio的教師的百分比應用
import android.content.Context;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity{
int MaxInt;
private Button button;
private EditText ETmax;
private TextView TV1;
private TextView TV2;
private TextView TV3;
private TextView TV4;
private TextView TV5;
private TextView TV6;
private TextView TV7;
private TextView TV8;
private TextView TV9;
private TextView TV10;
private TextView TV11;
private TextView TV12;
private TextView TV13;
private TextView TV14;
private TextView TV15;
private TextView TV16;
private TextView TV17;
private TextView TV18;
private TextView TV19;
private TextView TV20;
private TextView TV21;
private TextView TV22;
private TextView TV23;
private TextView TV24;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.firstscreen);
ETmax = (EditText) findViewById(R.id.editText);
TV1 = (TextView) findViewById(R.id.textView);
TV2 = (TextView) findViewById(R.id.textView2);
TV3 = (TextView) findViewById(R.id.textView3);
TV4 = (TextView) findViewById(R.id.textView4);
TV5 = (TextView) findViewById(R.id.textView5);
TV6 = (TextView) findViewById(R.id.textView6);
TV7 = (TextView) findViewById(R.id.textView7);
TV8 = (TextView) findViewById(R.id.textView8);
TV9 = (TextView) findViewById(R.id.textView9);
TV10 = (TextView) findViewById(R.id.textView10);
TV11 = (TextView) findViewById(R.id.textView11);
TV12 = (TextView) findViewById(R.id.textView12);
TV13 = (TextView) findViewById(R.id.textView13);
TV14 = (TextView) findViewById(R.id.textView14);
TV15 = (TextView) findViewById(R.id.textView15);
TV16 = (TextView) findViewById(R.id.textView16);
TV17 = (TextView) findViewById(R.id.textView17);
TV18 = (TextView) findViewById(R.id.textView18);
TV19 = (TextView) findViewById(R.id.textView19);
TV20 = (TextView) findViewById(R.id.textView20);
TV21 = (TextView) findViewById(R.id.textView21);
TV22 = (TextView) findViewById(R.id.textView22);
TV23 = (TextView) findViewById(R.id.textView23);
TV24 = (TextView) findViewById(R.id.textView24);
//TV1-8 how many wrong
//TV9-16 percentage
//TV17-24 letter grade
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MaxInt = Integer.parseInt(ETmax.getText().toString());
setContentView(R.layout.activity_main);
TV1.setText(MaxInt - 1);
TV2.setText(MaxInt - 2);
TV3.setText(MaxInt - 3);
TV4.setText(MaxInt - 4);
TV5.setText(MaxInt - 5);
TV6.setText(MaxInt - 6);
TV7.setText(MaxInt - 7);
TV8.setText(MaxInt - 8);
TV9.setText((int) Math.round((MaxInt - 1)/MaxInt) + "%");
TV10.setText((int) Math.round((MaxInt - 2)/MaxInt) + "%");
TV11.setText((int) Math.round((MaxInt - 3)/MaxInt) + "%");
TV12.setText((int) Math.round((MaxInt - 4)/MaxInt) + "%");
TV13.setText((int) Math.round((MaxInt - 5)/MaxInt) + "%");
TV14.setText((int) Math.round((MaxInt - 6)/MaxInt) + "%");
TV15.setText((int) Math.round((MaxInt - 7)/MaxInt) + "%");
TV16.setText((int) Math.round((MaxInt - 8)/MaxInt) + "%");
}
});
}
}
我不知道那是什麼,我期待的。有沒有其他方法? @Francesc – LUKER