Reputation: 349
When adding a field for entering a number(Number widget), the error "No speakable text present at Android Studio" takes off
content_main.xml:
activity_main.xml:
Upvotes: 24
Views: 128063
Reputation: 13
For <EditText>
, you have the following actions in Android Studio:
I hope this helps.
Upvotes: 0
Reputation: 1680
In my case, I was seeing these "errors" in the Issue Panel. I did not have any content descriptions set to "" in any of my XML files.
This "error" isn't a show-stopper and will not prevent you from compiling or distributing your app, but if you are a stickler for not wanting to see errors/warnings then you can always suppress this error:
In the Issue Panel, right click the error and left click on 'Show Quick Fixes'
Then select "Suppress this check if it is false positive" - the error should disappear from the Issues Panel.
Upvotes: 0
Reputation: 3
I faced the same problem. Then I solved the problem by replacing androidx.constraintlayout.widget.ConstraintLayout with LinearLayout and using android:hint.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Please write something"
/>
</LinearLayout>
Upvotes: 0
Reputation: 21
Just type in text view android:contentDescription="NULL" The error is gone example:-
<ImageButton
android:id="@+id/delButton"
android:layout_marginLeft="280dp"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/clear"
android:contentDescription="NULL"
/>
[N.B= ImageButton and Textview same rule work properly]
Upvotes: 2
Reputation: 51
For everyone who has the same error message as above, but the shown solutions were not helpful, you could try the following: Check if there is an empty (not set) android:contentDescription
field at any view in your *.xml file.
In my case I was adding an android:contentDescription
to a view but forgot to actually set it's value - after I was setting up a string variable for it. So it looked like this:
<TextView
android:id="@+id/textView_A"
android:text="@string/textView_A_text"
android:contentDescription=""/>
So Android Studio gave me the same "No speakable text present" error message, but not for that specific view but for another, which was some views below the one I changed, where I did not even added the field android:contentDescription
.
After adding my string variable like in the following code, the error was gone.
<TextView
android:id="@+id/textView_A"
android:text="@string/textView_A_text"
android:contentDescription="@string/TextView_A_contentDescription"/>
Hope it helps.
Upvotes: 3
Reputation: 11
The solution is simple you just need to add the text into the hint part. search hint in search-bar ant type something in hint block. and hit Enter.
Upvotes: 1
Reputation: 1134
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" />
Upvotes: 30
Reputation: 41
The problem is missing constraints. Any view you add in Constraint layout, you must set the margins otherwise you will get those errors and even if your app managed to run, your edit text will not be place properly.
Add this to your editText;
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Let me know if it worked. Remember you can twick this to your desired position.
Upvotes: -8