tags:

views:

54

answers:

1

Hi,

I added dynamic message successfully to my progressdialog.But when adding the button it doesn't take the button Please help me out.

private Handler progressHandler = new Handler() {

            @Override
            public void handleMessage(Message msg) {

                // process incoming messages here
                switch (msg.what) {

                case 0:
                    // update progress bar
                    progressDialog.setMessage("" + (String) msg.obj);
                    break;
                case 1:
                    progressDialog.setMessage("" + (String) msg.obj);
                    finish();
                    break;
                case 2:
                    Log.d(TAG,"in case 2.........");
//                  progressDialog.cancel();
                    progressDialog.setMessage("" + (String) msg.obj);
                    progressDialog.setButton("HOME", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
//                          progressDialog.cancel();
                            finish();

                        }
                    });
                    break;

                }
                super.handleMessage(msg);
            }

        };

Regards, Rajendar Are

A: 

Hi,

I simply changed the code to this way for my convience.

private Handler progressHandler = new Handler() {

            @Override
            public void handleMessage(Message msg) {

                // process incoming messages here
                switch (msg.what) {

                case 0:
                    // update progress bar
                    progressDialog = new ProgressDialog(context);

                    progressDialog.setMessage("" + (String) msg.obj);
                    progressDialog.show();
                    break;

                case 1:
                    Log.d(TAG,"in case 1.........");
                    progressDialog.dismiss();


                     AlertDialog.Builder builder = new AlertDialog.Builder(context);
                       AlertDialog alertDialog = builder.create();
                       alertDialog.setTitle("Dialog");
                       alertDialog.setMessage("" + (String) msg.obj);
                       alertDialog.setButton("HOME", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finish();

                        }
                    });
                    alertDialog.show();


                    break;

                }
                super.handleMessage(msg);
            }

        };

If any one know how to add dynamic button to progress dialog please reply.

Regards, Rajendar Are.