在EditText上打开键盘

时间:2018-01-18 15:03:58

标签: android android-recyclerview android-edittext android-softkeyboard

Screenshot 1 Screenshot 2

我有一个/,/g,里面有一些狗屎,还有一个隐藏它的按钮,显示RecyclerView。问题是键盘没有打开。我尝试过一切,但它不会起作用。

EditText

这就是EditText的样子。

<EditText
    android:id="@+id/klasseEditItem"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_marginStart="6dp"
    android:layout_margin="3dp"
    android:text="TextView"
    android:textSize="18sp"
    android:ems="10"
    android:inputType="text"
    android:focusableInTouchMode="true"/>

1 个答案:

答案 0 :(得分:0)

在这里,试试这个

 public static void showKeyboard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    }
}
相关问题