when i add the FloatingActionButton using graphique methode the android stuio appears to me this error "floatbutnID <com.google.android.material.floatingactionbutton.FloatingActionButton>: No speakable text present"
floatbutnID <com.google.android.material.floatingactionbutton.FloatingActionButton>: No speakable text present how could correct this
Speakable text is simply text that will be spoken by the system in phones for blind people. You can set it to "" if you don't need it.
This is the property for the speakable text
android:contentDescription="Your text"
You should look for information carefully before asking a question on Stack Overflow - it's in the rules of the forum. Please keep this in mind, otherwise you might get a bad reputation for duplicating questions.
I found the answer in 3 seconds in this question
if you are using xml, add android:contentDescription="content description" to the floatingActionButton tag. or in Java fab.setContentDescription(" content description") fab is the name of your floatingActionButton.
example
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="content description"/>
Alternatively in Java
FloatingActionButton fab = findViewById(R.id.fab);
fab.setContentDescription("content description");
Related
When adding a field for entering a number(Number widget), the error "No speakable text present at Android Studio" takes off
enter image description here
content_main.xml: enter image description here
activity_main.xml: enter image description here
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" />
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.enter image description here
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.
how can I make a custom password textfield like the picture in android programmatically java ? (or XML)
Im only interested to the textfield (the keyboard is android's system)
thank you
Password TextField Image
Import library in app.gralde
implementation 'com.poovam:pin-edittext-field:1.2.3'
XML layout for password field
<com.poovam.pinedittextfield.CirclePinField
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
app:noOfFields="4"
android:textSize="16sp"
android:textSelectHandle="#drawable/text_handle"
app:circleRadius="15dp"
app:fillerRadius="2dp"
app:fillerColor="#color/colorPrimary"
app:fieldBgColor="#ddd"
android:id="#+id/circleField"/>
Reference : https://github.com/poovamraj/PinEditTextField
I think this library can help you. It's easy and simple.
https://github.com/alphamu/PinEntryEditText
You just go to that link and follow the steps.
Let's say I am making a blog application about news. Whole idea is getting blog posts and showing them in application. I am parsing posts from RSS feed.
Every blog post has some amount of text,some pictures and a youtube video. I want to show everything exactly like in website. But all I can do is showing only text in text view:
<TextView
android:id="#+id/postContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textSize="18sp"
android:textColor="#color/postTextColor"/>
In post view activity:
final TextView mPostContent = (TextView) findViewById(R.id.postContent);
mPostContent.setText(Html.fromHtml(content).toString().replace("","").replace('\r', ' '));
This helps me to show text only. But as I mentioned blog post have more than one images. What should I do? Using webview is not a solution.
You can parse all the data using the RSS feeds and create a specific screen to display this parsed data the way you like.
It depends by the object format of your posts variable, maybe can it helps an adapter to a recyclerView and a CardView with the adapter class the with json or xml parser get the from the api response objects
I have this problem accessing TextView inside Relative Layout inside LinearLayout
Let's say I have these views in the file row.xml
<LinearLayout>
<TextView android:id="#+id/title" />
<RelativeLayout android:id="#+id/a_parent">
<TextView android:id="#+id/a">
</RelativeLayout>
<RelativeLayout android:id="#+id/b_parent">
<TextView android:id="#+id/b">
</RelativeLayout>
</LinearLayout>
Now I want to change the value of TextViews from an activity
LayoutInflater li=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout temp=(LinearLayout) li.inflate(R.layout.row, null);
((TextView)temp.findViewById(R.id.title)).setText("This is title");
RelativeLayout rl=(RelativeLayout)temp.findViewById(R.id.a_parent);
((TextView)rl.findViewById(R.id.a)).setText("an this is the content of a");
I can successfully set the TextView of id 'title', but an error appears when approaching the last line. It says that the error was caused by android.content.res.Resources$NotFoundException: String resource ID #0x1
Can anyone tell me what is wrong, how to fix it, and why does the code not work as I expected?
Thanks
Your Exception is a ResourcesNotFoundException for a String. Are you setting the value of the TextView using getString? And if so, are you sure that this string exists in your strings.xml file? If not, did you maybe reference one of your views with R.string.name instead of R.id.name? It looks like you modified your code for posting, it may be easier to help if you posted exactly what you're doing in the original, as well as the full stack trace.
Sometimes problems with Resources occur because the R file isn't up to date with new code. I would also try Rebuilding/Cleaning your project and see if that helps.
Usually this error comes when you are trying to set the integer value in Textview
like below :
textview.setText(1);
In this case the android will think that the integer value as string resource id and checks for
the string the strings.xml and throws Resources$NotFoundException.
Please check your code. If not post your necessary code and logcat output.
LinearLayout temp=(LinearLayout) li.inflate(R.layout.row....
in Your XML file, LinearLayout has not "android:id" property is declared.
I created an Activity displays an ImageView on the screen. I want get haptic feedback when the image is clicked.
In the main layout main.xml I added the next ImageView tag:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/image"
android:src="#drawable/dog"
android:onClick="doBark"
android:hapticFeedbackEnabled="true"/>
Then, in the Activity code I add this method:
public void doBark(View v) {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
Log.d("BarkingDog", "is hapticFeedbackEnabled: " + v.isHapticFeedbackEnabled());
}
When I click on the image I can see that doBark() is called and the output of the Logcat says "is hapticFeedbackEnabled: true", but I can't feel anything. I've also tried with the other two HapticFeedback constants, and no luck.
I know that HapticFeedback is enabled because each time I press the menu button, the device vibrates.
Any ideas? Suggestions?
PS: I don't want to use the Vibrator object. By using it, I can make the device vibrate, but I don't think it's the right way to do it.
Take a look at this: http://groups.google.com/group/android-developers/browse_thread/thread/de588e3d15cb9055?pli=1
Do note that it is old though, but the last time I had to use haptic feedback, I followed what Dianne had to say here