Я определил CustomKeyBoard в файле keyboard.xml в папке «xml» и добавил этот keyboard.xml в activity_layout.xml. Я хочу, чтобы моя CustomkKeyboard загружалась автоматически, когда начинается моя активность, но она загружается, когда я касаюсь EditText. Мой код:Загрузите пользовательский KeyBoard автоматически, не касаясь EditText в Android
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?
Вызов 'showKeyboardWithAnimation();' непосредственно из onCreate()? –