Question

My app has an EditText that, when I click in it to enter text in the Emulator, brings up a soft keyboard. I don't want this confounded thing to begin with, but then, like the visiting loud-mouthed uncle in the plaid pants, doesn't want to go away, and it is blocking the button beneath it. How do I either (a) prorgrammatically prevent the soft keyboard from appearing or at least (b) evict it, albeit manually, when it pops up?

Was it helpful?

Solution

Provided that the user is not supposed to input text, but is able to click the EditText and then add text in some other way, you could change the EditText to a TextView and then apply the following three tags to it in the layout file:

style="@android:style/Widget.EditText"
android:editable="false"  
android:focusableInTouchMode="false"

This will make it look like an EditText, but behave like a TextView.


Since you want the user to be able to write stuff in the EditText there are in my opinion two solutions:

  1. Leave it be. To remove the keyboard, all you need is to hit the back button once and every Android user knows this. It's standard behaviour.
  2. Wrap everything but the Button you say dissapears in a ScrollView. The ScrollView will then wrap its content to allow the Button to be shown in between the keyboard and the ScrollView.

OTHER TIPS

Just set android:editable="false" for your EditText

The answer is to set the focus on an other View like a Button, TextView or similar:

// REQUEST FOCUS
viewName.setFocusableInTouchMode(true);
viewName.requestFocus();

I think what you really need is take a look at android:windowSoftInputMode attribute in Manifest.xml Look into this link.

You can specify the screen to pan/ resize to show the buttons that the input method might be blocking. Not allowing the keyboard to show will make the user unable to enter text at all!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top