Cómo detener el teclado virtual que se muestra automáticamente cuando se cambia el enfoque (evento OnStart)

Estoy desarrollando una tableta con Android 2.2.

Tengo un formulario que estoy usando para instancias nuevas y editables. Cuando sea editable, quiero impedir que el usuario corrija ciertos campos. Puedo administrar esto en mi onStart -event, estableciendo el txt.setFocusableInTouchMode(false) . Esto fuerza el foco al siguiente EditText en mi forma (lo cual es genial), pero al ejecutar, el teclado EditText aparece automáticamente para el EditText con el foco. ¿Alguien sabe cómo detener esto?

Aquí está el código (llamado en el evento onStart ):

 private void PopulateFields(){ TextView txtTitle = (TextView) this.findViewById(R.id.txtEquipmentEditTitle); AutoCompleteTextView txtMake = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditMake); AutoCompleteTextView txtModel = (AutoCompleteTextView) this.findViewById(R.id.autEquipmentEditModel); EditText txtDesc = (EditText) this.findViewById(R.id.txtEquipmentEditDesc); TextView txtDeptKey = (TextView) this.findViewById(R.id.txtEquipmentEditDeptKey); EditText txtSerial = (EditText) this.findViewById(R.id.txtEquipmentEditSerialNo); EditText txtBarCode = (EditText) this.findViewById(R.id.txtEquipmentEditBarCode); txtTitle.setText("Edit Equipment"); txtMake.setText(make); txtModel.setText(model); txtDesc.setText(desc); txtDeptKey.setText(Integer.toString(deptKey)); txtSerial.setText(serial); txtBarCode.setText(barCode); txtMake.setEnabled(false); txtModel.setEnabled(false); txtDesc.setEnabled(false); txtMake.setClickable(false); txtMake.setFocusableInTouchMode(false); txtModel.setFocusableInTouchMode(false); txtDesc.setFocusableInTouchMode(false); txtMake.setFocusable(false); txtModel.setFocusable(false); txtDesc.setFocusable(false); } 

Tal vez esto le ayudará a:

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

Podemos Esconder el device Keybord siguiendo formas que dependen totalmente de la necesidad de situation_

First Way_

 EditText userId; /* * When you want that Keybord not shown untill user clicks on one of the EditText Field. */ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); 

Second Way_ InputMethodManager

  /* * When you want to use service of 'InputMethodManager' to hide/show keyboard */ InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(userId.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 

Third Way_

  /* * Touch event Listener * When you not want to open Device Keybord even when user clicks on concern EditText Field. */ userId.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { int inType = userId.getInputType(); // backup the input type userId.setInputType(InputType.TYPE_NULL); // disable soft input userId.onTouchEvent(event); // call native handler userId.setInputType(inType); // restore input type userId.setFocusable(true); return true; // consume touch even } }); 

En nombre de todas las formas anteriores, también puede definir windowSoftInputMode en la aplicación s manifest` file_

 <manifest ... > <application ... > <activity android:windowSoftInputMode="stateHidden|stateAlwaysHidden" ... > <intent-filter> ... </intent-filter> </activity> </application> </manifest> 

Espero que esto ayude a todos!

Esta es la respuesta: En su AndroidManifest.xml agregue un atributo a la Actividad:

  <activity android:name=".MyActivity" android:windowSoftInputMode="adjustPan"> </activity> 
  • Motorola Bionic - tipo de entrada textPersonName y textCapWords no funcionan
  • Cierra / oculta el teclado suave de Android en MvxFragment
  • ¿La interfaz de usuario se bloquea cuando se muestra el software mientras se reproduce el reproductor de medios?
  • Cómo cambiar el fondo clave de cualquier tecla en el teclado suave de Android
  • Mostrar un teclado virtual de android en el diseño gráfico de eclipse
  • EditText en ListView con windowSoftInputMode adjustPan
  • Android Linear Layout peso y teclado suave cuestión
  • Cómo ajustar el diseño cuando aparece el teclado virtual
  • ListView - mantiene el elemento específico en la vista cuando aparece el teclado virtual
  • Cómo evitar que el teclado suave de Android redimensione mi actividad
  • Auto Collapse ActionBar SearchView en Soft Keyboard cerrar
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.