1

In my mainactivity, I have several radiobuttons (2 groups), a 'go' button and on the bottom of the screen an EditText field.

When a user selects the EditText field, the keyboard pops up. The first thing I want is that the 'go' button remains and that the 2 radiogroups containing multiple radiobuttons disappear. That way, the screen layout remains as simple as possible.

Also, when the user cancels the EditText input (pressing back button on device), I would like the MainActivity (screen with all buttons and the edittextfield) to reappear.

The first part works when I setVisibility of the RadioGroups to View.INVISIBLE within the onClick listener of the EditText field.

However, when a user cancels input in the EditText field (keyboard disappears) the layout remains in that specific view: only the 'go' button & edittextfield are visible on the screen.

How can I handle the cancel/back button of the device when using an EditText field and make it restart an activity or reappear previously hidden layout elements?

fx772
  • 25
  • 6

1 Answers1

0

There are a couple of ways to achieve this effect:

  • Override the android:configChanges in the Manifest in order to handle the keyboard visible/hidden event yourself, as discussed in this dev guide.
  • Implement a custom layout that will listen for keyboard visibility changes and will allow you to make changes to your UI, as discussed in this SO question
Community
  • 1
  • 1
Egor
  • 39,695
  • 10
  • 113
  • 130