0

I have handled back button to close activity instead of hiding keyboard. It works just fine.

But if device has no hardware buttons software button will show hide keyboard (arrow down instead of back) image when keyboard is open. Of course clicking that down ("back") does close my activity.

This is what i have:

enter image description here

This is what i would like to have instead:

enter image description here

Is it possible to force software back button look like back button (instead of close keyboard) when keyboard is opened?

Ben
  • 175
  • 1
  • 2
  • 12
  • 7
    I would highly advise *not* doing what you've described. Users have certain expectations for what those buttons are going to do, and when you override that, it's going to frustrate them. If my intention is to hide the keyboard when I press the back button, I'm going to be highly irritated when it instead closes the application. Overriding the expected user experience is a *bad* idea. – Kevin Coppock Oct 01 '12 at 21:22
  • I do understand that. But then what would be the solution for activity that should always show keyboard? I do open keyboard on activity start and there is no point of hiding it. – Ben Oct 02 '12 at 13:10
  • What if your app is running on a device with a hardware keyboard? I don't know what you're working with, so you may have a legitimate reason for doing this, but my suggestion would be to not force the keyboard to be open, let it be hidden, just have a button to force it back up if there's not an EditText or something that you're working with. There are devices with *very* limited screen size, so having the keyboard constantly up makes for very little leftover space. – Kevin Coppock Oct 02 '12 at 13:57
  • @kcoppock Thanks, it's a good point about devices with hardware keyboard... What I'm doing is an Activity where user needs to enter one number select one spinner item and / or check box mark and leave. So my goal is to make it as little actions as possible. That's why i open keyboard on Activity open. Now about the back; If you get to that activity and keyboard is opened by default, by clicking BACK you kinda expect to get back to where you were before - previous activity, but instead of that you will get close of the keyboard. Thoughts? – Ben Oct 02 '12 at 18:13
  • I like the idea to make the user input as quick and easy as possible. I think by now most users will expect the back button to hide the keyboard (if displayed), so instead I might recommend implementing the ActionBar (particularly the "Up" button) to save the data and navigate away, or alternatively the [Done/Discard pattern](https://plus.google.com/113735310430199015092/posts/R49wVvcDoEW#113735310430199015092/posts/R49wVvcDoEW) suggested by Roman Nurik. – Kevin Coppock Oct 02 '12 at 20:05
  • @kcoppock I do have ActionBar in that activity so UP is working. About the Done / Discard - I strongly think that these actions should not be in the top of the screen and I prefer putting them at the bottom (just above the keyboard if it is opened). Reason is simple - it's hard to reach top of the screen if you hold your device with one hand. And I also think that main action button should be BIG - reasonable afc. And well... all this is out of the topic what to do with back button, I may let it hide the keyboard and display lots of empty space and require 2nd back click to leave activity... – Ben Oct 02 '12 at 20:44
  • Well my opinion was that you could use the Done/Discard (at the bottom is actually what I would recommend) and leave the default functionality for the back button. That way they can still exit in one button press, but you retain the expected functionality of the back button (hiding the keyboard). – Kevin Coppock Oct 02 '12 at 20:58

0 Answers0