在添加用于输入数字的字段(数字小部件)时,出现错误"No speakable present at Android Studio“
content_main.xml:enter image description here activity_main.xml:enter image description here
发布于 2021-09-17 11:13:46
问题是您缺少视图的内容标签,您应该添加内容描述,这样用户就可以简单地了解他应该在视图中输入什么数据
例如,如果您希望用户输入他想要的cookies数量,则应添加内容描述,如下所示:
android:contentDescription="Enter How Much Cookies You Want"
您还应该添加一个android:提示,以便用户可以在他们面前看到您想要输入的数据的示例,例如:
android:hint="e.g 5"
因此,视图XML代码应该如下所示
<EditText
android:id="@+id/editTextNumber2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:minHeight="48dp"
android:contentDescription="Enter How Much Cookies You Want"
android:hint="e.g 8" />
发布于 2022-01-16 07:25:35
解决方案很简单,您只需将文本添加到提示部分。在搜索栏中搜索提示,然后在提示块中键入内容。然后按Enter键。enter image description here
发布于 2021-09-11 12:00:20
问题在于缺少约束。任何你在Constraint layout中添加的视图,你必须设置边距,否则你会得到这些错误,即使你的应用程序成功运行,你的编辑文本也不会被正确放置。
将这个添加到你的editText中;
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
如果起作用了,请告诉我。记住,你可以将它旋转到你想要的位置。
https://stackoverflow.com/questions/69142705
复制相似问题