¿Cómo deshabilitar el teclado popup cuando en edittext?

En mi aplicación la primera vista de todas mis pantallas es un EditText, así que cada vez que voy a una pantalla aparece el teclado en pantalla. ¿Cómo puedo deshabilitar este pop-up y activarlo cuando se hace clic manualmente en el EditText ????

eT = (EditText) findViewById(R.id.searchAutoCompleteTextView_feed); eT.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if(hasFocus){ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(eT.getWindowToken(), 0); } } }); 

Código xml:

 <ImageView android:id="@+id/feedPageLogo" android:layout_width="45dp" android:layout_height="45dp" android:src="@drawable/wic_logo_small" /> <Button android:id="@+id/goButton_feed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="@string/go" /> <EditText android:id="@+id/searchAutoCompleteTextView_feed" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toLeftOf="@id/goButton_feed" android:layout_toRightOf="@id/feedPageLogo" android:hint="@string/search" /> <TextView android:id="@+id/feedLabel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/feedPageLogo" android:gravity="center_vertical|center_horizontal" android:text="@string/feed" android:textColor="@color/white" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ButtonsLayout_feed" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" > <Button android:id="@+id/feedButton_feed" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_margin="0dp" android:layout_weight="1" android:background="@color/white" android:text="@string/feed" android:textColor="@color/black" /> <Button android:id="@+id/iWantButton_feed" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_margin="0dp" android:layout_weight="1" android:background="@color/white" android:text="@string/iwant" android:textColor="@color/black" /> <Button android:id="@+id/shareButton_feed" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_margin="0dp" android:layout_weight="1" android:background="@color/white" android:text="@string/share" android:textColor="@color/black" /> <Button android:id="@+id/profileButton_feed" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_margin="0dp" android:layout_weight="1" android:background="@color/white" android:text="@string/profile" android:textColor="@color/black" /> </LinearLayout> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/feedListView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@id/ButtonsLayout_feed" android:layout_below="@id/feedLabel" android:textSize="15dp" > </ListView> 

La tercera vista (EditText) es donde está el foco.

La mejor solución reside en el archivo de manifiesto de proyecto (AndroidManifest.xml) , agregue el siguiente atributo en la construcción de activity

Android: windowSoftInputMode = "stateHidden"


Ejemplo:

  <activity android:name=".MainActivity" android:windowSoftInputMode="stateHidden" /> 

Descripción:

  • El estado del teclado virtual, ya sea oculto o visible, cuando la actividad se convierte en el foco de atención del usuario.
  • El ajuste realizado en la ventana principal de la actividad – si se cambia el tamaño más pequeño para dejar espacio para el teclado virtual o si su contenido se desplaza para hacer que el foco actual sea visible cuando parte de la ventana está cubierta por el teclado virtual.

Introducido en:

  • Nivel de API 3.

Enlace a Documentos

Nota: Los valores establecidos aquí (distintos de "stateUnspecified" y "adjustUnspecified") invalidan los valores establecidos en el tema.

Tienes que crear una vista, por encima del EditText, que tiene un foco "falso":

Algo como :

 <!-- Stop auto focussing the EditText --> <LinearLayout android:layout_width="0dp" android:layout_height="0dp" android:background="@android:color/transparent" android:focusable="true" android:focusableInTouchMode="true"> </LinearLayout> <EditText android:id="@+id/searchAutoCompleteTextView_feed" android:layout_width="200dp" android:layout_height="wrap_content" android:inputType="text" /> 

En este caso, utilicé un LinearLayout para solicitar el enfoque. Espero que esto ayude.

Esto funcionó perfectamente … gracias a Zaggo0

Añada debajo el código de su clase de actividad.

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

El teclado saltará cuando el usuario haga clic en el botón EditarTexto

  edittext.setShowSoftInputOnFocus(false); 

Ahora puedes usar cualquier teclado personalizado que quieras.

Puede utilizar el siguiente código para desactivar el teclado OnScreen.

 InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(editText.getWindowToken(), 0); 

La gente ha sugerido muchas grandes soluciones aquí, pero he utilizado esta técnica simple con mi EditText (nada en java y AnroidManifest.xml es necesario). Simplemente establezca su focusableInTouchMode focusable en false directamente en EditText.

  <EditText android:id="@+id/text_pin" android:layout_width="136dp" android:layout_height="wrap_content" android:layout_margin="5dp" android:textAlignment="center" android:inputType="numberPassword" android:password="true" android:textSize="24dp" android:focusable="false" android:focusableInTouchMode="false"/> 

Mi intención aquí es utilizar este cuadro de edición en la actividad de bloqueo de la aplicación donde estoy pidiendo al usuario que introduzca el PIN y quiero mostrar mi PIN personalizado. Probado con minSdk = 8 y maxSdk = 23 en Android Studio 2.1

Introduzca aquí la descripción de la imagen

Declare la variable global para InputMethodManager:

  private InputMethodManager im ; 

Bajo onCreate () lo define:

  im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); im.hideSoftInputFromWindow(youredittext.getWindowToken(), 0); 

Establezca onClickListener a ese texto de edición dentro de oncreate ():

  youredittext.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { im.showSoftInput(youredittext, InputMethodManager.SHOW_IMPLICIT); } }); 

Esto funcionará.

Utilice el código siguiente, escríbalo en onCreate()

 InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); 

Dos Soluciones Simples:

La primera solución se agrega debajo de la línea de código en el archivo xml del manifiesto. En el archivo de manifiesto (AndroidManifest.xml), agregue el atributo siguiente en la construcción de actividad

Android: windowSoftInputMode = "stateHidden"

Ejemplo:

 <activity android:name=".MainActivity" android:windowSoftInputMode="stateHidden" /> 

La segunda solución es añadir la siguiente línea de código en la actividad

 //Block auto opening keyboard this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

Podemos usar cualquier solución de arriba. Gracias

Intentarlo ……. i resolver este problema con el código: –

 EditText inputArea; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); inputArea = (EditText) findViewById(R.id.inputArea); //This line is you answer.Its unable your click ability in this Edit Text //just write inputArea.setInputType(0); } 

Nada u puede entrar por la calculadora del defecto en cualquier cosa pero u puede fijar cualquier secuencia.

intentalo

Prueba con esto:

 EditText yourEditText= (EditText) findViewById(R.id.yourEditText); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); 

Para cerrar, puede utilizar:

 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0); 

Pruébelo de esta forma en su código:

 ed = (EditText)findViewById(R.id.editText1); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(ed.getWindowToken(), 0); ed.setOnClickListener(new OnClickListener() { public void onClick(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(ed, InputMethodManager.SHOW_IMPLICIT); } }); 

Utilice el siguiente código en su onCreate()

  editText = (EditText) findViewById(R.id.editText); editText.requestFocus(); editText.postDelayed(new Runnable() { public void run() { InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.hideSoftInputFromWindow( editText.getWindowToken(), 0); } }, 200); 

Lo único que tienes que hacer es añadir android:focusableInTouchMode="false" al EditText en xml y eso es todo (si alguien todavía necesita saber cómo hacerlo con la forma más fácil)

En una aplicación de Android que estaba construyendo, tenía tres EditText s en un LinearLayout organizado horizontalmente. Tuve que evitar que el teclado suave aparezca cuando el fragmento se cargue. Además de fijar LinearLayout en true en el LinearLayout , tuve que establecer descendantFocusability a blocksDescendants . En onCreate , he llamado requestFocus en LinearLayout . Esto evitó que el teclado apareciera cuando se creara el fragmento.

Diseño –

  <LinearLayout android:id="@+id/text_selector_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="3" android:orientation="horizontal" android:focusable="true" android:focusableInTouchMode="true" android:descendantFocusability="blocksDescendants" android:background="@color/black"> <!-- EditText widgets --> </LinearLayout> 

En onCreatemTextSelectorContainer.requestFocus();

Use esto para activar y desactivar EditText ….

 InputMethodManager imm; imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (isETEnable == true) { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); ivWalllet.setImageResource(R.drawable.checkbox_yes); etWalletAmount.setEnabled(true); etWalletAmount.requestFocus(); isETEnable = false; } else { imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY,0); ivWalllet.setImageResource(R.drawable.checkbox_unchecked); etWalletAmount.setEnabled(false); isETEnable = true; } 

Para usuarios de Xamarin:

 [Activity(MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait, WindowSoftInputMode = SoftInput.StateHidden)] //SoftInput.StateHidden - disables keyboard autopop 

Pruebe esta respuesta,

 editText.setRawInputType(InputType.TYPE_CLASS_TEXT); editText.setTextIsSelectable(true); 

Nota: sólo para API 11+

 private InputMethodManager imm; ... editText.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.onTouchEvent(event); hideDefaultKeyboard(v); return true; } }); private void hideDefaultKeyboard(View et) { getMethodManager().hideSoftInputFromWindow(et.getWindowToken(), 0); } private InputMethodManager getMethodManager() { if (this.imm == null) { this.imm = (InputMethodManager) getContext().getSystemService(android.content.Context.INPUT_METHOD_SERVICE); } return this.imm; } 

Bueno, tuve el mismo problema y acabo de abordar con focusable en el archivo XML.

 <EditText android:cursorVisible="false" android:id="@+id/edit" android:focusable="false" android:layout_width="match_parent" android:layout_height="wrap_content" /> 

Usted probablemente está buscando seguridad también. Esto ayudará en eso también.

Para cualquier textview en su actividad (o crear textfiew vacío falso con android: layout_width = "0dp" android: layout_height = "0dp") y añadir para este texto siguiente: android: textIsSelectable = "true"

Si alguien sigue buscando la solución más fácil, establezca el siguiente atributo en true en su diseño padre

 android:focusableInTouchMode="true" 

Ejemplo:

 <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:focusableInTouchMode="true"> ....... ...... </android.support.constraint.ConstraintLayout> 
  • Edición de altura del cuadro EditarText android
  • ¿Cómo utilizar EditText onTextChanged evento cuando presiono el número?
  • Formato EditarTexto a moneda con números enteros
  • ¿Cómo cambiar el contenido de EditText con Javascript?
  • Mostrar el último carácter de una contraseña en un EditText
  • Deshabilitar teclado en EditText
  • Centrarse en segundo edittext sólo si primero es no-vacío android
  • EditText y InputFilter causan la repetición del texto
  • Cómo detener la entrada después de que la longitud de EditText cruza un límite
  • Decimal separator comma (',') con numberDecimal inputType en EditText
  • Cómo deshabilitar mayúsculas automáticas de un EditText
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.