I am actually using my own set of number buttons in a fragment to add numbers in edittext, it works fine. problem is when I touch on edittext to paste or or remove a character at a certain position, it brings up the softinput I tried couple of solutions which are:
android:windowSoftInputMode="stateAlwaysHidden" //in Manifest
etNumber.setFocusableInTouchMode(false); //tried xml version of thisas well
etNumber.setFocusable(false);
final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getView().getWindowToken(), 0); //no luck with imm as well.
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); //This disables the softinput but on entire activity, I need softinput on another fragment.
I want it to behave:
- Start adding numbers when my custom keyboard numbers are being pressed.
- Show cursor at the position where user touches without softkeyboard, from here my custom backspace key will remove the last character, OR user would be able to paste at cursor position.
- Allow text selection without softinput popup.
- Cursor only comes into focus when user touches the edittext.
- And dont disturb the softinput on other fragments.