tags:

views:

176

answers:

1

In my application,i override the android's backkey default functions(by Override onkeydown).its works fine.But when a spinner components default selecting elements windows and virtual keypad(In Android 1.5) enter into the screen the default back keys functionality collapsed because of my overriding.

is there any way to solve this problem? or what is the name of virtualkeypadwindow and spinner components window? Thanks. . .

A: 

The problem is when there's a Dialog on screen that's actually a completely separate Activity, the dialog helpers just hide it from you. There's only 2 ways you could solve this (depending on what you're trying to do).

You could extend the type of dialog you're using and and override the onKeyPress inside you're derived class then use it instead of the system's default dialog.

public class MyDialog extends ProgressDialog {
    /*  ...  */

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            // handle the keypress
            return true;
        }
        return false;
    }
}

You could start up the Dialogs with the cancellable option then catch the cancel action... something like:

public class MyActivity implements OnCancelListener {
    /*  ...  */

    public void startDialog() {
        ProgressDialog pd = ProgressDialog.show(
            MyActivity.this,    // Context
            "Progress Title",   // title for dialog
            "Progress Message", // message for dialog
            true,               // indeterminate?
            true,               // cancellable?
            this                // onCancelListener()
        );
    }

    @Override
    public void onCancel(DialogInterface dialog) {
        // the user canceled out of the load dialog (hit the 'back' button)... do something here
    }
}
fiXedd
Thanks Fixedd...but in ANdroid1.5 VirtualKeypad?How can i handle this one?...
arams