In my application I have a autocomplete in first activity and some edittext in second activity.
When I run my code in emulator it works fine and I am not seeing any virtual keyboard on screen when program is excecuted.
But when I deploy it in device when the application loads, onfocus is directly on autocomplete and a keyboard pops out, and also when I navigate from first activity to second activity onfocus is on first edittext and keyboard pops out.
I want to disable this onfocus on all the page. how to do that ?
Take a look at this question:
Stop EditText from gaining focus at Activity startup?
That worked for me... I just put this line in the activity definition on Manifest.
<activity
...
android:windowSoftInputMode="stateHidden" >
</activity>
Related
I have created Custom Edittext in which i set the InputType as this.setInputType(InputType.TYPE_CLASS_NUMBER); but the problem is it working perfectly on below 7.0(nougat) but above 7.0 it show me alphanumeric keyboard.
one another weird thing happen is when I touch the EditText, I quickly get the soft numerical keyboard, but in less than a second it automatically changes to regular soft keyboard showing all letters. also when keyboard is open, than ill press back button, than keyboard close, but when i re-enter in Edittext. keyboard is not open until i click on onther edittext then current edittext
Is this issue in Nougat or I am doing something wrong
For information i have used code to setSoftInputMode to ADJUST PAN
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
|WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
and to set Numeric keypad use this.setInputType(InputType.TYPE_CLASS_NUMBER);
Edited -
when i remove -
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
|WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
from activity every thing work fine( number keypad open at number edittext , alphanumerical keypad open at alphanumerical edittext ) except the content not goes up-direction means keypad hide edittext(because ignorance of this property SOFT_INPUT_ADJUST_PAN)
Help appreciated thanks
I tried to use setInputType(InputType.TYPE_CLASS_NUMBER) on devices 7+ and didn't see the behaviour that you described. Looking for another thread, runnable or any callback which changing InputType of your EditText after opening or simultaneously.
Try setting softInputMode in your Manifest file, it might give you your desired behavior.
<activity
android:name=".YourActivity"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
There are lot of questions regarding android keyboard not opening ,when there is a focus on edittext.
And there are many ways also to open keyboard forcefully.However usually keyboard opens automatically on request focus. But in some cases it do not opens even there is a focus in edittext.
What usually happens behind that keyboard do not appears automatically as it usually does ?
For automatic keyboard, use the following
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
also this can help in manifest file :
<activity
android:name="com.example.activities.MyActivity"
android:configChanges="keyboard"
>
</activity>
I have an edittext in my activity, and on activity and on create view
I am setting the focus on the activity. while setting focus, I am also
trying to show the keyboard. It works on some devices, but on others it
just doesn't show.
I tried to step through the code and found that the view is not created, when
the show keyboard is called. Maybe that is the reason.
I am not sure what the problem is. Is there a way to make sure, that if a edit text
is in focus, the keyboard shows up on app start.
Thanks,
You can try to show the Soft Keyboard by calling the following line during onCreate:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
I hope that helps.
In your AndroidManifest.xml, add this attribute to the <activity> tag for the Activity you want the keyboard shown:
android:windowSoftInputMode="stateVisible"
I have a single activity class and it has a two EditTexts on the screen. When the activity launches the keyboard launches with it. Why is this? I did not request enter anything yet into the edit box. Why does it do this? And how can I get rid of this behavior?
Try setting your stateHidden in the manifest file for the activity:
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
and this might be helpful:
How to keep soft keyboard from opening on activity launch in Android?
friends,
i have a EditText on simple activity with a button.
when every i move from one activity to this acivity focus is automatically set to EditText and keyboard appears in phone.
i dont want to open keyboard untill i click on editText.
can any one guide me what should i do?
any help would be appriciated.
You can use the following line of code to make sure the keyboard doesn't pop up when the activity starts and only pops up when a user clicks into an EditText
Place it in the onCreate method of your activity
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
EditText.setInputType(InputType.TYPE_NULL);
You can also pass the same thing in AndroidMenifest file for that particular activity like:
<activity
android:name="Activity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" >
</activity>
This will also work for you :)