disable "done" button on numberDecimal keyboard android? - java

I'm making a calculator app in android and have set the keyboard to always be open in the manifest but if you press the done button it still closes.
is there any way to override this?
the code i have used in manifest:
android:windowSoftInputMode="stateAlwaysVisible"

You can use Handle and Runnable to enable keyboard .... with this code in Runnable:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(getCurrentFocus(),InputMethodManager.SHOW_IMPLICIT);
But I think you should create layout replacement keyboard.
:)
I read this and edit it because
imm.showSoftInput(autoSuggestionTextView,InputMethodManager.SHOW_IMPLICIT);
is error.

Related

Android app - show "Change Keyboard" settings dialog

I am developing an android app in Java that needs to be set up as a keyboard.
I want to have a button that when the user presses my app shows the following dialog box:
This is a quick settings dialog box to allow the user to choose the input method (keyboard) it wants to use from now on. It is a default Android setting that is accessible to any user.
Normally this setting shows up when you press the following shortcut next to the android navigation bar when a keyboard is opened:
But in the context I am working on, this option is not visible to the user. So I want my app to be able to show this setting to the user when it presses a button.
I know an app that does this exact thing, so I know that it is possible. However, I don't know how to code a button that displays a system dialog box like this one.
Could you please help me?
Thanks in advance!
After some more research I found the answer using an InputMethodManager object and the showInputMethodPicker() method in Java:
InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.showInputMethodPicker();

Android, how to show software keyboard on click

I have a dialog box in my Android app; it is the only EditText control on the dialog (the others are spinners and buttons), and so it gets focus when the dialog is shown. This prevents the on-screen keyboard from ever showing up, meaning you can't easily enter any text into the box unless you have a hardware keyboard.
I believe (but I couldn't swear to it) that this is because the control starts with focus, and the system check as to whether to show the keyboard or not happens in the onfocus event. Is there any way the programmatically show the on-screen keyboard?
In order to implement the ability to force the keyboard open when the user presses a button on the screen then the following should help.
InputMethodManager inputMethManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
However an alternative to help regain focus of the dialog window can be found below. This code should open the software keyboard for you by resetting any flags initially set by AlertDialog. This code should be placed after the creation of the dialog window.
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

Is it possible to hide the keyboard with a button?

In my app, I have a Tab system, and in one of the tab layouts, there is an EditText.
And if I go to a different tab, the keyboard stays up.
So I've added a button that would hide it:
So how do I set the Button to closing the keyboard? It would also be very helpful if the keyboard went away when switching tabs.
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getTabHost().getApplicationWindowToken(), 0);
}
This method hides the keyboard. Works in tab case. Just set on the each tab the same OnClickListener, which calls hideKeyboard().
What i've done in my app is try and not use a button to close the softkeyboard cause i'm already using a button, instead of your Done, called Del whcih empties out the EditText field. What i've done is on the first press of the EditText show the keyboard, and at a second press just hide it.
Try using this in the onClick callback function for the EditText, OR if you want to keep the Submit button, then add this on it's onClick listener and for every tab you have as well.
InputMethodManager keyboard = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
Hope this helps, cheers.
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
add these to the event when you want to hide soft keyboard...

Why doesn't the virtual keyboard go away?

I have a pretty simple screen with a couple of EditText widgets and a button. In the emulator, when I click on the EditText widget, a virtual keyboard comes up. However, I can't seem to get rid of it. Clicking on an empty space on the screen does not make it go away. Only clicking the virtual Return key or the hardware Back button makes it disappear.
I don't have a real Android phone handy, so is this an emulator only thing or will it be like this on the actual device. If it is, what can I do to make the virtual keyboard go away, when I click elsewhere on the form?
Click the back button. They keyboard is an activity. There's not an easy way to remove the keyboard when clicking on a random area of the screen.
AngryHacker , I woud refer you to this post how to close/hide the android soft keyboard.
Hope this helps.
I think in the emulator you can press Escape to hide the keyboard. On a real device there is a hide button on the keyboard or you can press elsewhere in the ui. That's how it works on my HTC Desire S anyway.
I lived this problem and i resolved it. This problem is about InputMethodManager.SHOW_FORCED value in my project. When i open keypad using SHOW_FORCEDthen when i try to close keypad, keypad was not closing.
For Example :
activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_FORCED);
If you use above way to open keypad, you may try to change SHOW_FORCED value with SHOW_IMPLICIT value
For Example :
activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
I have the Galaxy S2 which is running Andriod 2.3.6.
I was having issues with the keyboard not moving out of the way after entering the needed text when logging into websites. I found that hitting the hardware return button does take the virtual keyboard out of the way. But occassionally it will take the web browser back one page. Which is frustrating because then I have to re-enter the log in info for whatever web site I'm connecting too. Hopefully Android 4.x has solved some of these glitchy issues.
You can achieve this by doing the following steps:
Make the parent view(content view of your activity) clickable and focusable by adding the following attributes
android:clickable="true"
android:focusableInTouchMode="true"
Implement a hideKeyboard() method
public void hideKeyboard(View view) {
InputMethodManager inputMethodManager =(InputMethodManager)getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
}
Lastly, set the onFocusChangeListener of your edittext.
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
hideKeyboard(v);
}
}
});
Source

How to detect when Android software keyboard is hidden?

I need to detect when the android software keyboard is hidden. My activity currently responds to when the hardware keyboard is hidden but the software keyboard looks like it can only be implied through a size changed event.
Does anyone know of a way that a view or activity can receive a notification when the software keyboard is hidden by the user cancelling out of keyboard mode?
Would forcing the sof tkeyboard to always be visible help?
You can add this to your Activity's xml file to ensure the softkeyboard is always visible in that Activity:
android:windowSoftInputMode="stateAlwaysVisible"
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Theres no real way to check, but you can check if an action on it works or not
boolean isClosing = false;
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
isClosing = imm.hideSoftInputFromWindow(tabHost.getApplicationWindowToken(), 0);
This will return false if the keyboard was closed and true if it was open and is now being closed.
I solved this by just searching for the back key. When the back key is received I know that the soft keyboard will be cancelled.

Categories

Resources