Pretty simple; The dialog is showing. I press the back button on the phone, nothing happens. I've tried this, but it never gets called:
static void ProgressDialog(Context context)
{
String text = context.getString(R.string.dialog_loading_video);
vDialog = new ProgressDialog(context)
{
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
// Nothing hap开发者_Python百科pening here!
}
return super.onKeyDown(keyCode, event);
}
};
vDialog = ProgressDialog.show(context, "", text);
vDialog.getWindow().setGravity(Gravity.TOP);
}
First, get rid of the second assignment to vDialog
. Then, you need to make your dialog cancelable by calling setCancelable(boolean)
.
In line vDialog = ProgressDialog.show(context, "", text);
you create new Dialog that doesn't have overriden onKeyDown()
method. Replace this line with these code:
vDialog.setTitle("");
vDialog.setMessage(text);
vDoalog.show();
精彩评论