-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Marsad Maqsood edited this page Jan 24, 2022
·
10 revisions
- Dialog Type
- Title Text
- Content Text
- Cancelled On Touch Outside
- Dialog Cancellation
- Custom View
- Listeners
- Buttons
- Customization
- Dialog Gravity
StylishAlertDialog.NORMAL
StylishAlertDialog.ERROR
StylishAlertDialog.SUCCESS
StylishAlertDialog.WARNING
StylishAlertDialog.PROGRESS
StylishAlertDialog.CUSTOM_IMAGE
StylishAlertDialog(Context context, StylishAlertDialog stylishAlertDialog);
//Initialize dialog
StylishAlertDialog dialog = new StylishAlertDialog(this, StylishAlertDialog.NORMAL);
dialog.setTitleText(String text)
dialog.setContentText(String text)
dialog.setCancelledOnTouchOutside(false)
dialog.setCancellable(false)
dialog.setCustomView(View view, boolean withContent)
//set withContent to true if you want to show content text with custom view
//For example
View view = LayoutInflater.from(this).inflate(R.layout.custom_view,null, false);
dialog.setCustomView(view, true);
//dialog.setCustomView(editText, true);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
}
});
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//dialog dismissed
//dialog dismissed with animation
}
});
dialog.setCancelClickListener(new StylishAlertDialog.OnStylishClickListener() {
@Override
public void onClick(StylishAlertDialog stylishDialog) {
//dialog canceled
}
});
dialog.setConfirmClickListener(new StylishAlertDialog.OnStylishClickListener() {
@Override
public void onClick(StylishAlertDialog stylishDialog) {
}
});
dialog.setCancelButton("Cancel", new StylishAlertDialog.OnStylishClickListener() {
@Override
public void onClick(StylishAlertDialog stylishDialog) {
}
});
dialog.setConfirmButton("Confirm", new StylishAlertDialog.OnStylishClickListener() {
@Override
public void onClick(StylishAlertDialog stylishDialog) {
}
});
dialog.setNeutralButton("Neutral", new StylishAlertDialog.OnStylishClickListener() {
@Override
public void onClick(StylishAlertDialog stylishDialog) {
}
});
dialog.getButton(StylishAlertDialog.BUTTON_CONFIRM).setEnabled(false);
dialog.getButton(StylishAlertDialog.BUTTON_CANCEL).setEnabled(false);
- Hide buttons after changing the alert type
dialog.getButton(StylishAlertDialog.BUTTON_CONFIRM).setVisibility(View.GONE);
dialog.getButton(StylishAlertDialog.BUTTON_CANCEL).setVisibility(View.GONE);
- Set the buttons stroke width
dialog.setStrokeWidth(12f);
dialog.setContentTextSize(int value);
- Change button color
dialog.getButton(StylishAlertDialog.BUTTON_CONFIRM).setBackgroundTintList(ColorStateList.valueOf(Color.GREEN));
dialog.getButton(StylishAlertDialog.BUTTON_CANCEL).setBackgroundTintList(ColorStateList.valueOf(Color.YELLOW));
- Set background color of buttons
dialog.setConfirmButtonBackgroundColor(Integer color);
dialog.setCancelButtonBackgroundColor(Integer color);
dialog.setNeutralButtonBackgroundColor(Integer color);
- Set button text color
dialog.setConfirmButtonTextColor(Integer color);
dialog.setCancelButtonTextColor(Integer color);
dialog.setNeutralButtonTextColor(Integer color);
dialog.getWindow().setGravity(Gravity.CENTER);