keyboard.xml 파일에서 'xml'폴더에 CustomKeyBoard를 정의하고이 keyboard.xml을 activity_layout.xml에 추가했습니다. 내 CustomkKeyboard가 내 활동이 시작될 때 자동으로로드되어야하지만, EditText를 만질 때로드되고 싶습니다. 내 코드는안드로이드에서 EditText를 건드리지 않고 사용자 정의 키보드를 자동으로로드
private CustomKeyboardView mKeyboardView;
private View mTargetView;
private Keyboard mKeyboard;
mKeyboard = new Keyboard(this, R.xml.keyboard);
mTargetView = (EditText) findViewById(R.id.ed_2d_res);
mTargetView.setFocusable(true);
mTargetView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
showKeyboardWithAnimation();
return true;
}
});
mKeyboardView = (CustomKeyboardView) findViewById(R.id.keyboard_view);
mKeyboardView.setKeyboard(mKeyboard);
mKeyboardView.setOnKeyboardActionListener(new BasicOnKeyboardActionListener(this));
}
private void showKeyboardWithAnimation() {
if (mKeyboardView.getVisibility() == View.GONE) {
Animation animation = AnimationUtils.loadAnimation(Add2d.this, R.anim.slide_in_bottom);
mKeyboardView.showWithAnimation(animation);
}
}
edittext를 터치하지 않고 사용자 지정 키보드를로드 할 수있는 방법이 있습니까?
onCreate()에서 직접'showKeyboardWithAnimation(); '을 호출 하시겠습니까? –