Defining labels for Accessibility spoken feedback - java

I'm looking for how to do texttospeech from extern file, eg from resources.
Normally it works that, it read view's text/className/etc .
There would be great to click on specific view eg unnamed button with only image, and tts from resource with mapped strings.
EDIT:
Yes it goes for TalkBack, yes It reads "Button", and I would like to assign it a specific string.
Also assign text for specific button even if it has text assigned in xml layout.
EG:
<Button
android:id="#+id/this_is_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="#string/self_destruct"
android:onClick="selfDestruct" />
and it will read the content from android:text. Or just "Button" if we have not assigned text here.
The problem is how to assign for this button another text which would be read.

Please take a look at this site:
http://developer.android.com/guide/topics/ui/accessibility/apps.html
It describes what to do to make you arr better in terms of Accessibility.
The Labeling User Interface Elements section should be important to you:
http://developer.android.com/guide/topics/ui/accessibility/apps.html#label-ui
Here is an example how to label a ImageButton:
<ImageButton
android:id=”#+id/add_note_button”
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src=”#drawable/add_note”
android:contentDescription=”#string/add_note”/>
More information about android:contentDescription: http://developer.android.com/reference/android/view/View.html#attr_android:contentDescription
You can set there any string from your resources so the message can be localized the same way as any other text displayed on screen etc.
Please note that android:contentDescription works even on view that have text associated (then the android:contentDescription will be spoken instead)

Related

How to use a Tag-like Edit Text in Android

Is there any way to create a EditText similar to the very same Tag system available here, in StackOverflow, when asking a question?
Or any library for the same purpose?
I want to do something similar in my app:
I already have an EditText field and, where the user inputs a topic, for instance, 'java', and then, when the user inputs ';', I want to mark that word in a color, blue or gray for example, to highlight that it is a tag. Then, the user can input another tag, i.e 'android', or can delete the previous tag like it was a text.
You're describing chips.
You can take a look at the MaterialChipsInput library. Instead of using an EditText you'll use ChipInput:
<com.pchmn.materialchips.ChipsInput
android:id="#+id/tag_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="Add a tag" />

How to put security patch on Text view?

I don't know what to say to this but I want mask or put patch on Text view.
See the picture below. I want effect like this. I've searched lot but didn't find any post with same requirement. How to achieve this?
You can pass two images in one TextView Like below Code:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/icon"
android:drawableRight="#drawable/pacth_icon"
/>
use
android:drawableLeft
and
android:drawableRight
to set your images in TextView.And you can setText and background Image as well.

EditText auto suggestions are blank or non existing

I have a standard straight forward EditText, I want to show the dictionary suggestions on top of this EditText so I did this in the XML:
<EditText
android:id="#+id/messaging_messageEdit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_weight="85"
android:background="#drawable/clanz_edit_text_holo_dark"
android:ems="10"
android:hint="Type your message here..."
android:singleLine="true"
android:inputType="textAutoComplete"
android:textColor="#dedede" >
</EditText>
I thought that the inputType parameter would take care of the auto dictionary view. On my phone (Nexus Android 5.1) the dictionary view appears but is blank. On a Genymotion emulator (Android 4.1.1) it does not display at all.
What am I missing?
This can be one solutions if you are looking for AutoComplete TextView.
<AutoCompleteTextView
android:id="#+id/from_station"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/enter_start"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColorHint="#color/transparent_black" />
You can also set threshold value using paramters.
Need to set adapter values at runtime.
If I understand correctly you want the keyboard to have auto correction right?
According to the Android developers website:
Can be combined with text and its variations to specify that this
field will be doing its own auto-completion and talking with the input
method appropriately. Corresponds to TYPE_TEXT_FLAG_AUTO_COMPLETE.
This is not what you're looking for. You are probably looking for textAutoCorrect which is this according to the Android developers website:
Can be combined with text and its variations to request
auto-correction of text being input. Corresponds to
TYPE_TEXT_FLAG_AUTO_CORRECT.
I've made a lot of apps and never used one of those though. It just auto corrects if you have a normal EditText.
I had the same problem not getting keyboard suggestions on some of my EditText views. Please pay attention there is a difference between autoComplete text views and getting keyboard suggestions while typing! They happen in two different places, first one inside the AutoCompleteTextView the other one on top of your keyboard while typing.. (for example you type te => it suggests "tea teaspoon teapot" to make your life easier.)
To achieve that I had to turn off the input types that I was setting programmatically and when you do so, the default behavior is back and that means getting keyboard word suggestions:
// etFieldValue.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
I tried the following but I still did not get a keyboard suggestions:
etFieldValue.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
at the end I commented all the above and it worked just fine!
here I also found that someone else had the reverse problem meaning they wanted to disable this functionality and they suggested to use the code that I had commented! read here

I want the TextView to end in one Line...how to do it

i am developing an app, i would have linked an image but i don't have enough reputation to do so....my problem is The text doesn't fit in one line it goes to the second line,obviously thats because i have set the height to "wrap_content",but i want it to show the text only in one line and not 2 or more,what should i change the height to?i don't want any java code for this,my fragment is already heavy with lots of code,is there any way to do this on xml, so that it doesn't display different results for different screen size?also is there any way i can append "..." to the end of the name? like "backupRestoreConf..." or something like that?
use android:maxLines="1" (or android:singleLine="true", but it was deprecated and now it is not anymore. What to think.)
android:maxLines="1"
Use this in your XML
you need to set this in xml for your textview:
android:singleLine="true"

recording user selections and altering textview strings via java code

Im new to android programming (and java for that matter). Although i do have a good grasp on programming concepts.
what im trying to do as an exercise to help build my understanding is create a simple text adventure. i want to begin by offering the user the ability to select something like a player race or class (which will ultimately determine how the story plays out). i plan on doing so with radio buttons (or perhaps even a normal button).
my question is this. when the user selects their class (ie: "Mage") i want that choice to be stored. from there i want to be able to define a conditional statement that will alter which story the user will be given. the problem is that i do not yet have a grasp on the process for recording the users selection, and altering the text in a textview (or any other view)
once i know how to record which variable the user chose and test it in an "if" statement, then alter the output of a view from within this conditional, i will be on my way.
thanks in advance =)
First you would want to create a radio group in your layout XML file and then give each radio button an id value to reference from the java code like this:
<RadioGroup android:id="#+id/RadGroup">
<RadioButton android:id="#+id/Rad1"
android:text="Radio1"/>
<RadioButton android:id="#+id/Rad2"
android:text="Radio2"/>
<RadioButton android:id="#+id/Rad3"
android:text="Radio3"/>
</RadioGroup>
Then from there you could use an if statement or a switch statement and as for altering a TextView you could use myTextView.setText("myString") and you could use that within each if to achieve different text values.

Categories

Resources