0
I cannot call a alertDialog inside a Fragment. At the moment of setting the Builder(this) it returns error. Follows code:
public void mostrarMsg(String titulo, String mensagem) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(titulo);
builder.setMessage(mensagem);
builder.show();
}
This code normally works inside an Activity when it is called, but when it is placed inside a Fragment returns error in 'this'. What is the reason and how it can be solved?
Puts the Getactivity() that will suit this, it will return to Activity that the Fragment is contained.
– GabrielLocalhost