Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set InputType to InputType.TYPE_CLASS_NUMBER in Android Version 7.0 (nougat) and above

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

like image 501
sushant gosavi Avatar asked Sep 12 '17 13:09

sushant gosavi


1 Answers

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.

like image 180
Dima Kozhevin Avatar answered Sep 18 '22 12:09

Dima Kozhevin