Skip to content

Instantly share code, notes, and snippets.

@punit9l
Created August 31, 2018 11:07
Show Gist options
  • Save punit9l/7589b4da380ceb03213495dcff066ef6 to your computer and use it in GitHub Desktop.
Save punit9l/7589b4da380ceb03213495dcff066ef6 to your computer and use it in GitHub Desktop.
private void showAlertDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
// Get the layout inflater
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.alert_dialog, null);
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(view);
final AlertDialog dialog = builder.create();
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
ImageView imageButton = view.findViewById(R.id.imageButton);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment