Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to show an Alert Dialog in Android?

$
0
0
  1. publicstaticvoid showDialog(finalContext context, finalString title, finalString message){
  2.  
  3.  
  4.   MainThread.run(context, newRunnable(){
  5.   @Override
  6.   publicvoid run(){
  7.   AlertDialog.Builder builder =new AlertDialog.Builder(context);
  8.   builder.setTitle(title);
  9.   builder.setMessage(message);
  10. DialogInterface.OnClickListener buttonListener =new DialogInterface.OnClickListener(){
  11.                                         @Override
  12.         publicvoid onClick(DialogInterface dialog, int which){
  13.                                 dialog.dismiss();
  14.                         }
  15.                 };
  16.         builder.setPositiveButton("Ok", buttonListener);
  17.         builder.show();
  18.      }
  19.   });
  20. }

Viewing all articles
Browse latest Browse all 178

Trending Articles