Instead of the app showing the interface below, it pulls the OnRestart method straight and displays "Program Restarted" when I open the app. How can I correct that ?
Code:
TextViewtInforme;EditTexttValor;ButtonbtDescobrir;protectedstaticfinalStringCATEGORIA="Exercicio";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(CATEGORIA, getClassName() + ".onCreate()) chamado: " + savedInstanceState);
TextView t = new TextView(this);
t.setText("Programa reiniciado");
setContentView(t);
setContentView(R.layout.activity_exercicio1);
tInforme = (TextView) findViewById(R.id.tInforme);
tValor = (EditText) findViewById(R.id.tValor);
btDescobrir = (Button) findViewById(R.id.btDescobrir);}
public void setbtDescobrir(View v) {
String guessStr = tValor.getText().toString();
int theGuess = Integer.parseInt(guessStr);
int tValor = theGuess%2;
if (tValor == 0){
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("O número é : ");
alertDialog.setMessage("O número é par !");
alertDialog.show();
}
else if (tValor == 1){
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("O número é : ");
alertDialog.setMessage("O número é ímpar !");
alertDialog.show();
}
}
@Override
public void OnRestart()
{
super.onRestart();
Log.i(CATEGORIA, getClassName() + ". onRestart() chamado.");
}
private String getClassName()
{
String s = getClass().getName();
return s.substring(s.lastIndexOf("."));}
}