i want to set textview text in alertbox. I want to make the countdown box. My code is as follow:
My custom alert box.

```
public abstract class ChallengeDialog extends AlertDialog.Builder implements OnClickListener {

    TextView msg;

 /**
  * @param context
  * @param title resource id
  * @param message resource id
  */
 public ChallengeDialog(Context context, String title, String message) {
  super(context);
  setTitle(title);
//  setMessage(message);
  msg = new TextView(context);
  msg.setText(message);
  setView(msg);

  setPositiveButton("accept", this); //In android this is OK button
  setNegativeButton("reject", this);//In android this is cancel button
 }

public void setDialogMsg(String m){
     msg.setText(m);
     setView(msg);
 }

 /**
  * will be called when "cancel" pressed.
  * closes the dialog.
  * can be overridden.
  * @param dialog
  */
 //This is cancel button
 public void onOkClicked(DialogInterface dialog) {
  dialog.dismiss();
 }

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

  if (which == DialogInterface.BUTTON_POSITIVE) { 

    dialog.dismiss();

  } else {

      onOkClicked(dialog);

  }

 }

 /**
  * called when "ok" pressed.
  * @param input
  * @return true, if the dialog should be closed. false, if not.
  */
 //This is challenge button 
 abstract public boolean onCancelClicked(String input); 

}

```

code to use custom alert box

```
ChallengeDialog chlngDialog = new ChallengeDialog(MyActivity.this,"title","count") {

                            @Override
                            public boolean onCancelClicked(String input) {
                                // TODO Auto-generated method stub
                                return false;
                            }

                        };

                        AlertDialog a = chlngDialog.show();

                        for(int i = 15 ; i>0 ;i--){

                            try {
                                chlngDialog.setDialogMsg("count "+i);
                                Thread.sleep(1000);

                            } catch (InterruptedException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
//a.dismiss();

```

I am executing this code in click of listview. But the alert box is display after the 15 secs, i have click on listview item. I dont know why it is so?