RecyclerView 问题:EditText 失去焦点

2024-01-07

我已经放了一些EditText in RecyclerView因为我需要获得一些值。实现是这样的:

<android.support.v7.widget.RecyclerView
    android:layout_below="@id/firstrow"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true"
    android:descendantFocusability="beforeDescendants"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:id="@+id/rectable"
    android:layout_marginLeft="@dimen/table_margin"
    android:layout_marginRight="@dimen/table_margin"
    android:layout_marginBottom="300dp" />

这是带有一些内容的自定义 xmleditText:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white"
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="60dp ">


<TextView
    android:text="TextView"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:id="@+id/description"
    android:layout_weight="1"
    android:textColor="@color/black" />

<View
    style="@style/VerticalSeparator" />


<EditText
    android:hint="lol"
    android:id="@+id/weight"
    android:focusable="true"
    style="@style/DefaultEditCellStyle" />

<View
    style="@style/VerticalSeparator" />

<EditText
    android:hint="lol"
    android:id="@+id/arm"
    android:focusable="true"
    style="@style/DefaultEditCellStyle" />

<View
    style="@style/VerticalSeparator" />


<EditText
    android:hint="lol"
    android:focusable="true"
    android:id="@+id/moment"
    style="@style/DefaultEditCellStyle" />

实际上当我点击一个EditText它会打开键盘,失去焦点并立即关闭键盘,因此不可能在其中写入。我还尝试阅读其他问题,提出这个:

recyclerView.setFocusable(true);
        recyclerView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        recyclerView.setAdapter(adapter);

但是,在不同的listview,它不起作用。

我该如何解决这个问题? 谢谢


最后我用这个解决了它:

 android:focusableInTouchMode="true"
 android:descendantFocusability="beforeDescendants"

在 RecyclerView 的布局中,我将其添加到清单中:

android:windowSoftInputMode="stateHidden|adjustPan"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

RecyclerView 问题:EditText 失去焦点 的相关文章

随机推荐

  • 创建 IReadOnlyList

    我如何创建一个IReadOnlyList
  • 如何在启动 Inno Setup 安装程序时显示消息框

    如何在启动 Inno Setup 中制作的安装程序时显示消息框信息 就像 重装上阵的游戏 的设置一样 致电MsgBox功能 https jrsoftware org ishelp index php topic isxfunc msgbox
  • 导入 SQL Server 中现有的存储过程

    我从生产中恢复了我的开发数据库 但我的开发环境中所需的存储过程在我的生产数据库中不存在 是否有一个命令可以用来将开发的存储过程导入回 SQL Server 大约有 88 个文件 因为每个过程都在不同的文本文件中 蒂亚 克里斯 哎呀 您以痛苦
  • 将数据从块传递到视图

    我发现您可以通过将数据设置到 xml 文件来将数据设置到块视图 有没有办法在不访问 xml 文件的情况下设置它 还有一个问题 如何将数据从控制器传递到块 用于将数据从块传递到视图 在块中使用 this gt setVariableName
  • Android Wear:Google Play 服务已过时。需要 9256000 但找到 8701534

    我的 Android Wear 应用程序无法运行 每次尝试在手机上打开某些内容时 我都会在 logcat 中收到此错误 W GooglePlayServicesUtil Google Play services out of date Re
  • 如何使用构造函数在另一个类中创建对象?

    所以我正在编写我的代码 它是以模块化方式设计的 现在 我的一堂课 被称为Splash必须创建另一个类的对象 该类称为Emitter 通常 您只需创建对象并完成它 但这在这里不起作用 因为Emitter类有一个自定义构造函数 但是当我尝试创建
  • 协调器布局和相对布局问题

    当您在 android studio 中创建一个空白 Activity 时 这是给定的布局
  • libmagic。文本/纯文本而不是文本/javascript 文本/css

    我使用 libmagic 来获取项目 Web 界面中文件的 mime 类型 我在 css 和 js 文件上得到文本 纯 mime 类型 例如 Chromium 显示以下警告 Resource interpreted as Styleshee
  • cocoa应用程序中的资源文件夹路径

    我正在开发使用一些 c 文件的 Mac OS X 应用程序 并且我有一个配置文件 我将其添加到应用程序资源中 我的问题是 资源文件夹的相对路径是什么 I tried MyAppName app Contents Resources conf
  • MATLAB 与命名空间最接近的东西是什么?

    我的实验室里有很多 MATLAB 代码 问题是确实没有办法组织它 由于所有函数都必须位于同一个文件夹中才能调用 或者您必须将一堆文件夹添加到 MATLAB 的path环境变量 似乎我们注定会在同一个文件夹中拥有大量文件 并且全部位于全局命名
  • Java应用程序中的主要方法[重复]

    这个问题在这里已经有答案了 我们到处都读到要启动一个 java 程序 我们需要一个起点 那就是静态 main 方法 在 Java EE 应用程序中 main 方法位于何处 它是否内置在应用程序服务器 容器中 它是如何触发的以及我们可以对此进
  • 从 qrc 导入 qml 时 QtCreator 语法高亮

    当我从 qrc 位于不同的目录中 导入 qml 时 它可以编译并正常工作 但是当 Qt Creator 无法识别导入的组件并且不突出显示它时 这是代码 import QtQuick 2 0 import qrc qml libs Appli
  • 根据另一列更改一列的值

    这是同样的问题根据 pandas 中的另一个值更改一个值 https stackoverflow com questions 19226488 change one value based on another value in panda
  • 带有 sortKeys 和参数值的 Spring Batch Paging

    我有一个在 Spring Boot 中运行的 Spring Batch 项目 该项目工作得很好 对于我的读者 我将 JdbcPagingItemReader 与 MySql PagingQueryProvider 结合使用 Bean pub
  • youtube-dl 速率限制下载速度和自动恢复下载[关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我正在使用 shell 脚本进行视频转换 这是 shell 脚本 bin bash downloading video youtube d
  • Laravel Nova - 将 Nova 路径指向资源页面

    我需要将 Nova 路径指向资源 这样当用户登录时 他就会定向到该特定资源 我已更新此路径 config nova php path gt crm resources clients 现在登录后 我可以看到 URL 已更新 但页面仍然是We
  • 如何正确构建 KnockoutJS 应用程序

    我想知道如何以正确的方式构建 KnockoutJS 应用程序 官方文档几乎总是只使用一个 ViewModel 在仅实现了几个功能之后 我的代码变得非常混乱 并且来自面向对象的背景 我对这样的架构非常过敏 所以必须有更好的解决方案 由于对 J
  • 从 Java 调用 Mono 程序集

    我有一个用 C 编写的大型文本校对框架 我想编写一个使用这组库的 OpenOffice 扩展 我首选的语言是 Java 因此 我需要一种从 Java 访问 NET 程序集的方法 在 Windows 和Linux 有没有办法从 Java 调用
  • 程序化 MSIL 注入

    假设我有一个像这样的有缺陷的应用程序 using System namespace ConsoleApplication1 class Program static void Main string args Console WriteLi
  • RecyclerView 问题:EditText 失去焦点

    我已经放了一些EditText in RecyclerView因为我需要获得一些值 实现是这样的