Tuesday, November 2, 2010

[android-developers] Overriding Back Button Action in Activity

I have just overide my back button in my code like this

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {

return true;
}
return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
startActivity(new Intent(context, MainDialog.class));
finish();
return true;
}
return super.onKeyUp(keyCode, event);
}


Now I am facing a weird problem, I have a edit text on the current
Activity. At the time of editing when I am trying to close the virtual
keyboard by pressing the back button . My Application finishes... But
I just want to close the keyboard not the Avtivity.. Any suggestion to
solve my issue..?

Thanks in advance, Tanmay

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate