When adding a field for entering a number(Number widget), the error “No speakable text present at Android Studio” takes off

content_main.xml: enter image description here activity_main.xml: enter image description here

Answers

1.The problem is you are missing content labeling for the view, you should add content description so the user could simply understand what data he should enter into the view

for example, if you want the user to enter the number of cookies he wants you should add a content description as seen below:

android:contentDescription="Enter How Much Cookies You Want"

You should also add an android:hint so the user would have it in front of them an example of the data you want inputted for example:

android:hint="e.g 5"

So your views XML code should look as follows

<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" />
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐