问题
I am trying on a view as below:
- A EditText
- A RecycleView
Result: When I press on edit text, then there 2 keyboards which appear in order.
PS: THIS ISSUE DON'T HAPPEN WITH SINGLE EDIT TEXT!
Tested on device: Samsung A5, anroid 6.0.
Share screen shot and apk: https://drive.google.com/drive/folders/1Kw4DPk4iHtfXzVgrpTe4vzDwbRKvsy4X
<EditText android:id="@+id/editText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginLeft="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:ems="10" android:inputType="number" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/editText" />
回答1:
what did you mean? on Single edit text two keyboard appear or two different keyboard appears on two edit text.
Note: I checked your app it show only number keyboard cause in edit text,<android:inputType="number"/>
Here Code which you need
editText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_ENTER)
{
return true;
}
return false;
}
});
just add to your Activity.java
回答2:
At first time ,when activity lunch add this line in AndroidManifest file to hide keyboard.
android:windowSoftInputMode="stateHidden"
android:configChanges="orientation|screenSize|keyboardHidden"
And add this line in EditText Property.
android:imeOptions="actionDone"
This will hide your keyboard and only show when you click on EditText of Particuler Type as input type is Number in your xml. Hope this will help you.
来源:https://stackoverflow.com/questions/56573407/there-are-two-keyboards-appear-when-press-on-an-edit-text