I'm having trouble trying to switch from Activity
, simply not opening my new Activity
.
public void Add(View v){
try {
FormularioActivity.choise = 0;
startActivity(new Intent(RolavelMainActivity.this, FormularioActivity.class));
}catch (Exception e){
Toast.makeText(getBaseContext(), "Erro!", Toast.LENGTH_SHORT).show();
}
}
And this is Activity I want to open
public class FormularioActivity extends Activity {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference root = database.getReference();
DatabaseReference ameacas = root.child(RolavelMainActivity.AMEACAS_KEY);
public static EditText txtDescricao;
public static EditText txtEndereco;
public static EditText txtBairro;
public static EditText txtImpacto;
public static Button btEdit;
public static int choise = 0;
Button btAdd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.formulario_activity);
txtDescricao = (EditText) findViewById(R.id.txtDescricao);
txtEndereco = (EditText) findViewById(R.id.txtEndereco);
txtBairro = (EditText) findViewById(R.id.txtBairro);
txtImpacto = (EditText) findViewById(R.id.txtImpacto);
btAdd = (Button) findViewById(R.id.btAdd);
btEdit = (Button) findViewById(R.id.btEdit);
if (choise == 0) {
btEdit.setEnabled(false);
btAdd.setEnabled(true);
} else {
btEdit.setEnabled(true);
btEdit.setEnabled(false);
}
}
public void backForm(View v) {
finish();
}
public void add(View v) {
Ameaca aAmeaca = new Ameaca(txtDescricao.getText().toString(), txtEndereco.getText().toString(), txtBairro.getText().toString(), Integer.parseInt(txtImpacto.getText().toString()));
String key = ameacas.push().getKey();
ameacas.child(key).setValue(aAmeaca);
}
public void edit(View v) {
Toast.makeText(FormularioActivity.this, "Edição Efetuada", Toast.LENGTH_SHORT).show();
Ameaca aAmeaca = new Ameaca(txtDescricao.getText().toString(), txtEndereco.getText().toString(), txtBairro.getText().toString(), Integer.parseInt(txtImpacto.getText().toString()));
ameacas.child(RolavelMainActivity.key).setValue(aAmeaca);
txtDescricao.setText("");
txtEndereco.setText("");
txtBairro.setText("");
txtImpacto.setText("");
}
public void clearFields(View view) {
txtDescricao.setText("");
txtEndereco.setText("");
txtBairro.setText("");
txtImpacto.setText("");
}
}