如何隐藏键盘,并向EditText添加文本

时间:2015-09-30 23:04:45

标签: android android-layout android-edittext android-button

我有EditTextButton。 当您按EditText时,我希望不显示keyboard,当您按下Button时,我想在EditText上输入数字1。

观测 我希望cursor不会消失。

![ 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 ] 1

2 个答案:

答案 0 :(得分:1)

Set this in your EditText xml to disable the keyboard

android:focusableInTouchMode="false"

Set a "1" on your edit text.

mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mYourEditText.setText("1");
        }
    });

答案 1 :(得分:0)

Next configuration to your EditText:

android:longClickable="false"
android:clickable="false"
android:focusableInTouchMode="false"

Add a onClickListener to your button:

myButton.setOnClickListener(new View.OnCLickListener(){
    @Override
    public void onClick(View v) {
        myEditText.setText( myEditText.getText().toString() + "1");
    }
});