Created
December 19, 2014 22:05
-
-
Save dlfinis/b1e096b71601d4f87582 to your computer and use it in GitHub Desktop.
Button Listener with auto-close Alert Dialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private View.OnClickListener btnJagger_onClickListener = new View.OnClickListener() { | |
String message=""; | |
@Override | |
public void onClick(final View v) { | |
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); | |
message=(getString(R.string.thanks)+"\n"+getString(R.string.about)) ; | |
builder.setTitle(R.string.company_name); | |
builder.setMessage(message); | |
builder.setCancelable(true); | |
final AlertDialog dlg = builder.create(); | |
dlg.show(); | |
final Timer t = new Timer(); | |
t.schedule(new TimerTask() { | |
public void run() { | |
dlg.dismiss(); // when the task active then close the dialog | |
t.cancel(); // also just top the timer thread, otherwise, you may receive a crash report | |
} | |
}, 3000); // after 3 second (or 3000 miliseconds), the task will be active. | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment