I can not call an alertDialog inside a fragment. At the time of setting the builder (this) it returns error. Here is the 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 it returns error in 'this'. What is the reason and how can it be solved?