How to Prevent the Keyboard from Popping Up on Mobile Devices

How to prevent the keyboard from popping up on mobile devices?

When step up button is clicked, the input will be focus, so mobile device display keyboard, the solution is add readonly attribute, when user click input box, remove it, on blur, add readonly attribute again.

see the code snippet to understand

$( "#spinner" ).spinner();$( "#spinner" ).click(function(event){  $(this).removeAttr('readonly').select();});$( "#spinner" ).blur(function(event){  $(this).attr('readonly', 'readonly');});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script   src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"   integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E="   crossorigin="anonymous"></script><link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">  <input id="spinner" >

Android on-screen keyboard auto popping up

You can use the following line of code in the activity's onCreate method to make sure the keyboard only pops up when a user clicks into an EditText

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

How to disable keyboard popup?

As I already wrote in the comment use the getWindow() method of your host-activity to set the SOFT_INPUT_STATE_AL‌​WAYS_HIDDEN flag. There is no need to invoke anything on an EditText when you want to disable the up-popping keyboard generally in this specific activity.

How to prevent keyboard from opening when activity is opened in android?

Just add this line of code in your onCreate(...) method

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);


Related Topics



Leave a reply



Submit