【问题标题】:Android 7.0 : editText in a listview does not show keyboard on requesting focusAndroid 7.0:listview 中的 editText 在请求焦点时不显示键盘
【发布时间】:2017-02-14 23:21:45
【问题描述】:

我有一个ListView,其中包含EditText作为项目,并且在ListView 标头中还包含EditText

当我点击任何EditText 时,它会显示键盘并允许我输入文本。但是如果我按下后退按钮,它会隐藏键盘,然后点击之前聚焦的EditText,不会打开键盘。

这是我在 xml 中声明的EditText

<EditText
    android:id="@+id/ui_row_create_poll_edit_text_txt_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="@dimen/margin_normal"
    android:layout_toLeftOf="@id/ui_row_create_task_user_info"
    android:background="@android:color/transparent"
    android:imeOptions="actionNext"
    android:maxLength="@integer/task_length"
    android:maxLines="1"
    android:paddingBottom="@dimen/padding_large_plus_little"
    android:paddingLeft="@dimen/padding_large_plus_little"
    android:paddingTop="@dimen/padding_large_plus_little"
    android:textColor="@color/black"
    android:textSize="@dimen/font_very_large" />

我已尝试添加onFocusedchanged 监听器和onTouchListener,但它不起作用。

我也尝试添加onClickListener并添加以下代码以强制显示键盘,但这也不起作用。

 InputMethodManager inputMethodManager = (InputMethodManager) context.
    getSystemService(Context.INPUT_METHOD_SERVICE);
 inputMethodManager.showSoftInputFromInputMethod(windowToken, 0);

它在 Android-7.0 上运行良好,但在 API 24 中会导致问题。

Android 7.0 是否有与EditText 相关的具体变化?或者有人可以提出一些解决方案吗?

注意:我只在 Android-7.0 上遇到这个问题。在以前的版本上它工作正常。 我还遇到了另一个issue,它也只发生在 7.0

【问题讨论】:

  • @Anjali:焦点没有问题。问题是它没有打开键盘。 EditText 有焦点,光标在那里,但键盘没有打开

标签: android listview keyboard android-edittext


【解决方案1】:

我正在回答我的问题以结束此问题。我刚刚收到了 Android 7.0 的更新补丁,现在它工作正常。这似乎是 7.0 中的一个错误,已在 2016 年 10 月 5 日的安全路径中解决。

【讨论】:

    猜你喜欢
    • 2013-07-16
    • 2012-09-29
    • 1970-01-01
    • 2012-03-04
    • 1970-01-01
    • 2013-08-23
    • 2021-01-27
    • 2016-04-02
    相关资源
    最近更新 更多