I'm new to Android. I've spent two hours already for searching. Whatever i try softkeyboard is never shown for my EditText. I create it simply:
EditText editText = (EditText)findViewById(R.id.editText);
I tried:
editText.requestFocus();//i tried without this line too
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
and:
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus)
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
i also tried:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
i tried putting this line into AndroidManifest.xml file:
android:windowSoftInputMode="stateVisible|adjustResize"
but all in vain. It just never shows. What am i missing?
You need to make sure that your emulator is not set to use a hardware keyboard. This can be done by choosing Edit on a selected emulator in the AVD. Then uncheck the Hardware keyboard present setting.
You could also try using a different emulator, such as Genymotion. It supports full hardware acceleration (multi-core CPU as well as GPU) and runs much faster than any of the android emulator images. If you use Genymotion you will need to disable the hardware keyboard within Android (see below for details).
To disable hardware keyboard in Genymotion:
Go to Settings -> Language & input and open the Default item under Keyboard & Input Methods. There is a Hardware setting that you can toggle on/off. When it is on you use your physical keyboard and when it is off the standard soft keyboard should pop-up whenever a text field gets focus.
Screenshots for Genymotion settings:
In version 2.1.1
- click on your virtual device settings
- then select "use virtual keyboard for typing" checkbox.
The method for enabling the on-screen soft keyboard for Android Studio 2+ Emulators depends on the API level of the emulator. I have tested the various methods starting with API 15 and have recorded the steps below.
[A] APIs 15, 17, 19 and 21.
The following steps will enabled the on-screen soft keyboard but will disable the ability to enter text and interact with the AVD using the hardware computer keyboard.
In Android Virtual Device Manager (AVD), click the edit action for the device you wish to work with
Click Show Advanced Settings and scroll right down to the bottom of the page to the "Keyboard" section
Uncheck the "Enable keyboard input" option
[B] API 22
The soft keyboard is displayed no matter what you do with the hardware keyboard settings. If you wish to enable hardware keyboard support alongside the soft keyboard then,
In AVD, click the edit action for the
device you wish to work with
Click Show Advanced Settings and scroll right down to the bottom of
the page to the "Keyboard" section
Check the "Enable keyboard input" option
[C] API 23
If you wish to use the hardware and soft keyboard then...
Follow [B] steps 1 to 3
On the virtual device, Launch Settings, then select Language and input / Current Keyboard
Enable Hardware - Show input method
If you don't need the hardware keyboard, in AVD advanced settings, uncheck the "Enable keyboard input" option. You won't need to change any settings on the virtual device.
[D] APIs 24 and 25
Follow [B] steps 1 to 3 above, checking or unchecking the "Enable
keyboard input" option depending on whether you want to enable the hardqare keyboard.
On the virtual device, Launch Settings, then select Language and input / Physical Keyboard
Enable "Show virtual keyboard"
If the Enable keyboard input option was selected in the AVD then you will now be able to use both hard and soft keyboard inputs. If you unchecked the option in the AVD the soft keyboard will be displayed regardless.
[E] API 26
Exactly the same as [D] APIs 24 and 25 except you need to navigate through an additional "System" menu level in the device settings before you get to Language and input / Physical Keyboard
There are two places to deselect hardware keyboard in AS 1.1.0. This one isn't sufficient:
Must do this (click Tools | Android | AVD Manager; then create new or edit old AVD and then click Show Advanced Settings; scroll down and clear Enable keyboard input):
May be your emulator doesn't support softkeyboard..
Add a hardware property Keyboard support and set it to true for your emulator.
If it is already true then Check this answer.
To show:
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
And to hide:
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
Just try this one....
Related
I am developing an application where I have RFID reader (emulates keyboard). In some activities I need a virtual keyboard as well. I have discovered that all I need is to toggle "Use Physical Keyboard". That works fine, but when I restart my tablet, this feature is set to default?
Is it possible, if I can insert a toggle somewhere in my code?
I was able to toggle the on-screen keyboard, with the following code:
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
In reference, use EditText.
"EditText is a thin veneer over TextView that configures itself to be editable."
To display the on-screen keyboard, all they need do is touch in the textbox. If that box was named "Search" or something similar, I believe it would be more useful to a user than a button.
I would like to have both soft input and hard keyboard enabled in my android virtual device. I know how to have either but not BOTH.
The reason wanting for BOTH at the SAME time:
soft input: preview how the layout resizes when the screen is reduced by the keyobard
hard keyboard: obviously the quick input.
Thanks in advance.
Go to your AVD manager Tab then select the appropriate AVD then refer the "hardware menu" in that click on new button and select the keyboard support option to enable hardware keyboard.
Hope this is helpful to you.
yash.
Does anybody know how to programmatically disable the keyboard individual letter pop-up?
(This blue pop-up when you click in a letter on the virtual keyboard of the device.)
You can't do this from an application.
If the keyboard on a device is built to do this, the only option you have is to build/install/use a different keyboard that doesn't do it.
Applications are not capable of manipulating the system keyboard (except for small things like ime options, inputType etc.)
In your phone, go to Settings --> Language and Input --> Select the keyboard type that you are using. (In my case it says Samsung keyboard). Select the settings icon next to it. There is an option called "Character preview". Disable it.
I'm debugging an issue with the soft keyboard display not displaying when it should. However, I don't have a device handy for testing. The problem is that the emulator never shows the soft keyboard.
Some skins have a keyboard constantly displayed on the right, some don't, but none that I've tried so far has ever shown a keyboard on the device screen.
Is there some setting that I missed?
I found out how to do this on the Android emulator itself (Menu, "Settings" App - not the settings of the emulator outside). All you need to do is:
open settings app -> Language & Input -> Go to the "Keyboard & Input Methods -> click Default
This will bring up a Dialog in which case you can then disable the Hardware Keyboard by switching the hardware keyboard from on to off. This will disable the Hardware keyboard and enable the softkeyboard.
Here are the steps:
=> Settings
=> Language and Input
=> Default
=> Hardware Physical Keyboard
=> off to turn on the On Screen Keyboard
If you're using AVD manager add a hardware property Keyboard support and set it to false.
That should disable the shown keyboard, and show the virtual one.
Settings > Language & input > Current keyboard > Hardware Switch ON.
This option worked.
Settings > Language & input > Current keyboard > Hardware Switch ON.
It allows you to use your physical keyboard for input while at the same time showing the soft keyboard.
I just tested it on Android Lollipop and it works.
To be more precise, with Lollipop these are the steps I followed to show soft keyboard:
Settings > Language & Input;
under "Keyboard & input methods" label, select "Current Keyboard";
A Dialog named "Change Keyboard" appears, switch ON "Hardware", then select "Choose keyboards";
another Dialog appears, switch ON the "Sample Soft Keyboard". Here you get an alert about the possibility that keyboard will store everything you write, also passwords. Give OK;
Repeat above steps in order to show "Change Keyboard" Dialog again, here the new option "Sample Soft Keyboard" is available and you can select it.
NOTE: after that, you might experience problems in running you app (as I had). Simply restart the emulator.
Edit your virtual device using AVD.
Press the "show advance setting" button to show more option scroll
down to the bottom and check "Enable keyboard input" press "finish" button
at the bottom corner of your window
then start the emulator device that you just set up.
inside the emulator, go to the "Settings" -> "Language & Input"
and in the "Keyboard & Input Methods" -> "Default" then "choose
input method" is shown
and switch off "Hardware Physical Keyboard" toggle button
There is a bug in the new version of NOX app. Software keyboard doesn't work after switching to it in settings. To fix this, I installed Gboard using the Play Market.
Go to Tools > AVD Manager > Click on ▾ on the Respective Emulator and > Wipe Data and Restart, will solve the problem on New Android Studio.
Switch from physical to software keyboard.
Hi all,
I'm developing an application that will run on a tablet with Android 3.2.
I attached a physical keyboard to tablet then the software keyboard disappear.
Now I need to use the software keyboard in some activities, but I don't figure out how I can do that.
I tried different ways:
Android: show soft keyboard automatically when focus is on an EditText
http://dev.bostone.us/2009/11/04/android-show-and-hide-soft-keyboard-programmaticaly/#awp::2009/11/04/android-show-and-hide-soft-keyboard-programmaticaly/
http://plainoldstan.blogspot.com/2010/09/android-set-focus-and-show-soft.html
All these don't work if the physical keyboard is connected.
Someone know how can I achieve this goal?
Thanks
Under setting ther will be "Language & Input" >> Keyboard Setting >> "Input method selector" >> "Always show"
after you plug in the keyboard just put on the Keyboard ICON "on the bottom right of the screen" the select "USE PHYSICAL KEYBOARD" to off
Then the Soft keyboard (on screen) will appear normally until you unplug the keyboard.
In my case i use the barcode scanner instead of keyboard so I do need some softkeyboard however I use the USB hub and connect both barcode scanner and numeric keyboard.
hope this will help you.
Yes, when a keyboard is connected to the device, by default the soft keyboard is disabled. To enable it, we need to turn OFF hardware keyboard via:
Settings > Language & Input > Select Input Method
The option name may differ from device to device. We will be able to use the scanner along with the soft keyboard even though we turn it OFF.
And NO, there is no way currently to programmatically accomplish this. The most we can do is detect when a keyboard/scanner is connected and redirect the user to the Input Method selection window, by overriding the onConfigurationChanged method in your Application class:
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showInputMethodPicker();
Toast.makeText(this, "Barcode Scanner detected. Please turn OFF Hardware/Physical keyboard to enable softkeyboard to function.", Toast.LENGTH_LONG).show();
}
}
Actually we can use physical keyboard and soft keyboard simultaneously, what u have to do is that after connecting your physical keyboard, focus on any edittext, then you can see a keyboard icon on bottom right of your screen, click on it , it'll show all all available soft i/p options plus a Switch titled 'Show Virtual keyboard - keep it on screen while physical keyboard is active' - just check this option