0

I have an EditText and a Button. When you press EditText, I want to not show the keyboard, And when you press the Button, I want to type a number 1 on the EditText.

The observation I want to cursor does not disappear.

When you press the 1 1 writes When you press the Del licked Can be controlled in the text Without the appearance of the keyboard

madhan kumar
  • 1,560
  • 2
  • 26
  • 36
Karim Michel
  • 23
  • 1
  • 6

2 Answers2

0

@Karim Michel. You can use

For First Case .Hide Keyboard

   ETOBJ.setOnTouchListener(new View.OnTouchListener()
        {
            public boolean onTouch(View arg0, MotionEvent arg1)
            {
                InputMethodManager inputManager = (InputMethodManager) context.
                getSystemService(Context.INPUT_METHOD_SERVICE); 
                inputManager.hideSoftInputFromWindow(
                this.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS); 
                return false;
            }
        });

And when Press on Button you can use

setCursorVisible(false);
setText("1");
Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

try these codes:

your_edit_text.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            your_edit_text.setInputType(InputType.TYPE_NULL);
            EditText.setText("1");
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
             imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
             your_edit_text.setSelection(your_edit_text.getText().length()); // move cursor to end
        }
Milad gh
  • 211
  • 1
  • 11