因此,在模拟器中启动应用程序时出现此错误。该应用程序基本上做的是获取随机的两个数字并将它们输出到textviews。然后用户回答等式并按下按钮。该应用程序然后崩溃。我得到的错误是错误0x3009(EGL_BAD_MATCH)。这会在应用启动之前显示,但只会在按下按钮时终止应用。
public class levelone extends Activity {
private EditText numberEditText;
public int answer;
private int answerUser;
Context context;
private TextView answerText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_levelone);
answerText = (TextView) findViewById(R.id.answerTextView);
Random rand = new Random();
Random rand1 = new Random();
int number = rand.nextInt(10) + 1;
int numbers1 = rand1.nextInt(10) + 1;
TextView number1 = (TextView) findViewById(R.id.number1);
TextView number2 = (TextView) findViewById(R.id.number2);
String String1 = String.valueOf(number);
String String2 = String.valueOf(numbers1);
number1.setText(String1);
number2.setText(String2);
answer = number + numbers1;
Button answerButton = (Button) findViewById(R.id.answerButton);
answerButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
numberEditText.getText().toString();
answerUser = Integer.parseInt(numberEditText.getText().toString());
try {
answerUser = Integer.parseInt(numberEditText.getText().toString());
}
catch(NumberFormatException e){
answerUser = 0;
}
}
});