i m newcomer in android. i am faceing some trouble my Scenarios is -when i click button so open alertDailog and alertdailog have two button like send and cancel,when i click send button, i wanna to open a ProgressBar because send button have havy content, so take more time.
i m using handler but not found any exact solution
i m using this code
btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
handler.sendEmptyMessage(0);
}
});
alert = new Dialog(ProgramDetailActivity.this);
alert.setContentView(R.layout.dialog_email);
alert.setTitle(" Enter mail info");
alert.setCancelable(true);
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
finish();
}
};
btnSend = (Button) alert.findViewById(R.id.btnsend);
btnBack = (Button) alert.findViewById(R.id.btncancel);
alert.show();
btnSend.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("null")
public void onClick(View v) {
handler2.sendEmptyMessage(0);
// perform long opration progressDialog.dismiss();
toast=Toast.makeText(ProgramDetailActivity.this,"Mail has been sent Sucessfully!",
Toast.LENGTH_LONG); toast.show();
} }
private Handler handler2 = new Handler() { public void handleMessage(Message msg) { alert.hide(); alert.cancel(); alert.dismiss();
progressDialog = ProgressDialog.show(v.getContext(), "Email Sending", "Please wait...");
}
};