remove view keypad [duplicate] - android

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Close/hide the Android Soft Keyboard
I'm a beginner, and have written a simple program to find the roots of a quadratic equation. Entering values in the EditText fields works well, because the virtual keypad pops up so that you can enter your numbers. However, the keypad covers the TextView where your results appear. If the user knows it, they can press the "back" key, and the keypad is removed, revealing the results field. But I want the keypad to disappear when the user touches the "execute" button in the app without pressing the "back" key.
I have been researching this, and some suggested using finish(); But this doesn't only remove the keypad, it also exits the whole program.
So what's the easiest way to only remove the keypad, leaving the underlying TextView displayed? I want to include this in the onClick view that executes the math.
Any suggestions are appreciated.

Just add this code in the onClick method:
InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourSubmiBtn.getWindowToken(), 0);

Related

How to end EditText editing properly in Android?

I have EditText widget on my activity.
How should I make/handle "commit" in that text field?
I saw that some applications control keyboard and there is "Done" or "Ok" key instead of "Enter". Maybe this is how should I do it... But I don't know how how to do it.

How to prevent Button press from closing soft keyboard

I have implemented a note-taking UI where a WebView accepts user input and below it is a row of buttons that toggle formatting inside of the WebView. The buttons sit on the bottom of the layout, so when the soft-keyboard pops up when the WebView has focus the buttons sit just above the keyboard.
This is working great, but my problem is that whenever one of the buttons is pressed the soft-keyboard closes. I want to leave the soft-keyboard as it is whenever a button is pressed. So if it is closed, a button press won't open it, and if it is open then a button press won't close it.
I found the Wordpress Android source code, and the layout is extremely similar and it has the exact button-keyboard interaction I want.
The relevant sources on GitHub are here Activity Code and here Layout XML
I can't figure out how they do it though. They don't call the InputMethodManager, which I am trying to avoid if possible since it can cause jumpy behavior where the keyboard has to re-open itself whenever a button is pressed. The one similar question I found had answers that essentially said to do exactly that, or create a useless view to get the focus to prevent the keyboard from closing. Neither seem very efficient.

Enter and Return button in a single keyboard in android

I need my soft keyboard input to have both return button AND done button so that the user can write paragraphs in my EditText and click on Done to close the keyboard. Is this possible?
I've tried:
android:inputType="textMultiLine"
android:imeOptions="actionDone"
together but it didn't work.
PS: I'm testing on Samsung keyboard type.
No, I believe it's not possible prior to API level 11 (3.0).
The same issue cropped up here (discussed in the comments to the accepted answer):
Android Soft keyboard action button
From the final comment:
Looking at a few apps on my phone, it seems common to have the multiline box last, with a visible "Done" or "Send" button below it (e.g. Email app).

SoftKeyboard : Switch Keyboard

So my problem is as follows:
I am working on the "Unmodified SoftKeyboard Demo Project" , I created another keyboard (Azerty) with Copy/Paste as the Qwerty. When I call mInputView.setKeyboard(mAzertyKeyboard); by pressing a button , the keyboard is switched, but the layout is big and badly displayed, I mean I can't see all keys just the half of the keyboard on the screen. Does switching a keyboard require another call like Draw?
Thanks.
Check if the number of key in a row is the same as the qwerty keyboard.
Anyway, you should show us the layout here if you want some help

Android onscreen keyboard without any other keyboard

I've looked at several questions and come across several posts, but i'm not able to figure out how to do this.
The following picture shows you the basic layout :
I've created a custom numpad and put it up on the repo.
Currently, when the app opens, the edit text has the focus but and anything i enter with the keyboard will go into the edittext box. This part of the functionality works fine.
Problem: When i touch the edittext again, system Input Method with its huge keyboard pops up. How do i completely block it from popping up? Or, can i tell the app to use only my keyboard instead of the system one? (Or is the only way to write a custom ime?)
i cannot use NULL type input at the manifest because doing that makes the caret in the edittext disappear and moreover if there are two edit texts, i wouldnt know which has focus.
Any help would be highly appreciated!
You can do a few things:
Programmatically hide it in the whole app:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Hide it from the view it would be attached to:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
Set the input type of the EditText to 0:
EditText yourEditText=(EditText)findViewById(R.id.editTextConvertValue);
yourEditText.setInputType(0);

Categories

Resources