Try this method of passing the correct context into your DialogFragment
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
DP ciao = new DP();
ciao.show(view.getContext(),"MyDP");
}
});
In your original code, when calling
'ciao.show(this,"MyDP");'
the this refers to its parent class which is OnClickListener.
When assigning a click listener and overriding the onClick, you get passed the view and an argument which you can use to access information from, including the context.