When adding a phone number field I wrote the following XML:
<EditText
android:id="@ id/etPhoneNumber"
style="@style/my_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="@string/cdu_phone_number_hint"
android:inputType="phone"
android:autofillHints="phone"
android:digits=" 0123456789"
android:textColor="@color/black"
android:visibility="visible" />
However, even though I specified digits
, Android still displays those buttons for "wait", "pause" etc. Is there any way to NOT display those?
CodePudding user response:
THe keyboard is a separate app that gets to decide for itself what keys to show. The only control you have over it is the inputType, which serves as a hint to the keyboard for what you want. Apparently whatever keyboard you're using wants to show those keys too. You can't stop it. You could try changing the input type to number and see if you prefer that. But remember it will show up differently on different devices no matter what you do, because they'll use different keyboard apps (there is no single keyboard that's on every device, just some that are more common than others- and the user can always decide to install their own too).
CodePudding user response:
You need to use the InputMethodManager class InputMethodManager
/**
* Input method manager
* 输入法显示和隐藏
* @param show
*/
fun inputMethodManager(show:Boolean){
val imm: InputMethodManager = requireActivity().getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
if (show){
//show
binding.mainFrBehaviorAddWord.mainFrBehaviorEd.requestFocus()
binding.mainFrBehaviorAddWord.mainFrBehaviorEd.isFocusableInTouchMode = true
imm.showSoftInput(EditText, InputMethodManager.RESULT_UNCHANGED_SHOWN)
}else{//hide
imm.hideSoftInputFromWindow(EditText.windowToken, 0)
}
}