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.
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.
@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");
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
}