0
I own a Fragment and this fragment, has a Floatingactionbutton.
I invoke the method onClickListener:
FloatingActionButton floatingActionButton = (FloatingActionButton) view.findViewById(R.id.fabAddEventos);
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adicionarEvento(v);
}
});
When clicking, I invoke the method to add Wind passing the View as parameter to create a Dialog with several fields of Edit Text and Button.
public void adicionarEvento(View view) {
Dialog dialog = new Dialog(view.getContext());
EditText etEventos_nome = (EditText) view.findViewById(R.id.etEventos_nome);
Button btn_eventos_confirmar = (Button) view.findViewById(R.id.btn_eventos_confirmar);
btn_eventos_confirmar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
The error occurs in the Context or View Dialog, locking the application.
Ta very confused your question, what is the mistake? Put it here also
– Leonardo Dias
I re-asked the question. No error, however, crashes the app when invoking the setOnClickListener() de Button. In short, the logic is as follows: A Fragment has a Floatingactionbutton that opens a Dialog, the latter has a Button.
– Aislan Almeida
Try to do this: Dialog dialog = new Dialog(getActivity()); in place of Dialog dialog dialog = new Dialog(view.getcontext());, for that view getcontext() is taking the context of the method, not the class
– Leonardo Dias
I edited my answer below, see if it solves your problem.
– Edson Reis