Skip to content

Instantly share code, notes, and snippets.

@evasyuk
Created November 27, 2016 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evasyuk/b18fdc3c0a1547eb19071b66b198a45d to your computer and use it in GitHub Desktop.
Save evasyuk/b18fdc3c0a1547eb19071b66b198a45d to your computer and use it in GitHub Desktop.
// custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Title...");
// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Android custom dialog example!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment