I want to create a custom dialog box like below
I have tried the foll
This is an example dialog, create with xml.
the next code xml is just an example, the design or view is implemented here:
this lines of code are resources of drawable:
android:src="@drawable/dialog_cross"
android:background="@drawable/btn_flat_red_selector"
you could do a class extends Dialog, also something like this:
public class ViewDialog {
public void showDialog(Activity activity, String msg){
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.dialog);
TextView text = (TextView) dialog.findViewById(R.id.text_dialog);
text.setText(msg);
Button dialogButton = (Button) dialog.findViewById(R.id.btn_dialog);
dialogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}
finally the form of call, on your Activity for example:
ViewDialog alert = new ViewDialog();
alert.showDialog(getActivity(), "Error de conexión al servidor");
I hope its work for you.