default clicklistener for dialogs on Android
if you want to create a dialog that should close itself after the user pressed a button, instead of writing something like this:
Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.tutorial_title).setMessage(R.string.tutorial_message);
builder.setNeutralButton(getString(R.string.tutorial_ok), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
you could just as well pass null as a OnClickListener and it will do exactly the same thing:
builder.setNeutralButton(getString(R.string.tutorial_ok), null);
Written by Thomas Taschauer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Related Tags
#android
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#