0

EditText があり、ユーザーがこの EditText をクリックしたときにカスタム キーボードを表示する必要があります。(このキーボードをデフォルトに設定する必要はありません。editView で一度表示するだけです)

4

2 に答える 2

1

xmlで、次のように設定します

android:inputMethod="com.myapp.mykeyboard"
于 2013-02-18T07:55:54.100 に答える
1

キーボードのレイアウトを作成し、oncreate メソッドで次のようにします

    setContentView(R.layout.main);
        // adjusting key regarding window sizes
        setKeys();
        setFrow();
        setSrow();
        setTrow();
        setForow();
        mEt = (EditText) findViewById(R.id.xEt);
        mEt.setOnTouchListener(this);
        mEt.setOnFocusChangeListener(this);
        mEt1 = (EditText) findViewById(R.id.et1);

        mEt1.setOnTouchListener(this);
        mEt1.setOnFocusChangeListener(this);
        mEt.setOnClickListener(this);
        mEt1.setOnClickListener(this);
        mLayout = (RelativeLayout) findViewById(R.id.xK1);
        mKLayout = (RelativeLayout) findViewById(R.id.xKeyBoard);


@Override
public boolean onTouch(View v, MotionEvent event) {
    if (v == mEt) {
        hideDefaultKeyboard();
        enableKeyboard();

    }
    if (v == mEt1) {
        hideDefaultKeyboard();
        enableKeyboard();

    }
    return true;
}
private void hideDefaultKeyboard() {
    getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

}
private void enableKeyboard() {

    mLayout.setVisibility(RelativeLayout.VISIBLE);
    mKLayout.setVisibility(RelativeLayout.VISIBLE);

}

// Disable customized keyboard
private void disableKeyboard() {
    mLayout.setVisibility(RelativeLayout.INVISIBLE);
    mKLayout.setVisibility(RelativeLayout.INVISIBLE);

}
于 2013-02-18T08:00:14.043 に答える