parkingwang / vehicle-keyboard-android

停车王车牌键盘-Android
Other
658 stars 148 forks source link

键盘没有默认显示 #50

Closed GirlFriendNotFind closed 4 years ago

GirlFriendNotFind commented 4 years ago

我已确认所提问题在 FAQ.md 及 Issues 上没有。 这样设置键盘没有默认显示,一定要点击输入才显示键盘 final InputView mInputView = view.findViewById(R.id.input_view); final KeyboardView keyboardview = view.findViewById(R.id.keyboardview); final Button btChange = view.findViewById(R.id.bt_change); KeyboardInputController.with(keyboardview, mInputView) .useDefaultMessageHandler().setDebugEnabled(false) .addOnInputChangedListener(new OnInputChangedListener() { @Override public void onChanged(String number, boolean isCompleted) { } @Override public void onCompleted(String number, boolean isAutoCompleted) { if(!isAutoCompleted){//点击确定按钮 dismissAllowingStateLoss(); } } }) .bindLockTypeProxy(new KeyboardInputController.ButtonProxyImpl(btChange) { @Override public void onNumberTypeChanged(boolean isNewEnergyType) { super.onNumberTypeChanged(isNewEnergyType); if (isNewEnergyType) { btChange.setTextColor(getResources().getColor(android.R.color.holo_green_light)); } else { btChange.setTextColor(getResources().getColor(android.R.color.black)); } } }) .setMessageHandler(new MessageHandler() { @Override public void onMessageError(int message) { } @Override public void onMessageTip(int message) { } });

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clipChildren="false" android:orientation="vertical" android:padding="16dp"> <com.parkingwang.keyboard.view.InputView android:id="@+id/input_view" android:layout_width="match_parent" android:layout_height="60dp" android:layout_margin="6dp" app:pwkInputTextSize="22sp"/> <com.parkingwang.keyboard.view.KeyboardView android:id="@+id/keyboardview" android:layout_width="match_parent" android:layout_height="wrap_content"/> <Button android:id="@+id/bt_change" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="变更为:新能源"/>

GirlFriendNotFind commented 4 years ago

解决了,自己提前调用选中第一个输入框就行 mInputView.performFirstFieldView();