2015年9月3日 星期四

[Android ] The most popular code are used in android


// general setting
    final Context context = this;
    AlertDialog.Builder builder;
    private ProgressDialog progressDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

builder = new AlertDialog.Builder(context);
 builder.setMessage("When your IPCam is ready. Press OK to be continued.")
     .setTitle("")
     .setPositiveButton("OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
       int status= new NetworkAccess().isOnline(cm, builder, -1);
       if(status==0){
        exitAddCamera();
       }
      }
     })
     .setNegativeButton("Cancel",
       new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
         dialog.cancel();
        }
       })
     .setOnCancelListener(new DialogInterface.OnCancelListener() {
               @Override 
               public void onCancel(DialogInterface dialog) {
                AddCamera.this.finish();
               }
           }); 


AlertDialog dialog = builder.create();
        dialog.show();



 progressDialog = ProgressDialog.show(context, "Add camera", "Please wait....");

     if(progressDialog!=null){
      progressDialog.dismiss();
     } 


}

沒有留言:

張貼留言