Problem opening a new Activity

Asked

Viewed 34 times

0

I’m having trouble trying to change Activity, Just 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("");
    }
}
  • Displays some error message?!

  • Displays only the Toast Error I placed.

  • You declared Formularioactivity on Androidmanifest.xml?

  • Oops, missing that detail, kkkkkkkkkkkkkkkk

  • 1

    It was just that, thank you acklay

1 answer

1

There is no indication of errors in this section of your code. Most likely it may be the absence of your Activity in the AndroidManifest.xml. Check it and add the FormularioActivity if there is no.

<activity android:name=".FormularioActivity"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.