Android accessibility feature for TextView - android

Hi I have a view with a TextView and linear layout. Linear layout is a kind of custom keyboard with number of buttons. So every button click I have to do some validations and append a character to the TextView.
Click of each button I append the character to the textview. Now when I turn the Accessibility feature ON, it is expected to read out the last character that is entered. But what happens is every time I set text in the text view.. Accesibilty feature reads out the 1st char in the textview, not the last char..
so Im confused on how to control the accessiblity of textview.. Can anyone plz tell me how to control the accessibilty.

You could use the setContentDescription() on your TextView to set it to the character you just entered. Then when accessibility kicks in it will ask your TextView for its content description and it should work. See docs here:
https://developer.android.com/reference/android/view/View.html#setContentDescription(java.lang.CharSequence)

Related

How to make a listView with textview and spinner and edittext

How can i create an android listview with row 1: textview + spinner row 2: textview + edittext etc.?
I have to make a form and i make it with xml layout but it's too long and bad for perfomance as the eclipse says.
Thank you!
ListView can be used if there is a repetition of same views in every row. This is where you get performance benefits given by adapters' recycling view mechanisms. With every row having different views they cannot be recycled and therefore no point in using the listview there.
So based on what kind of rows you have here are two solutions:
Solution 1:
Row 1 has textview + spinner, Row 2 has textview + EditText. And this combination repeats for the rest of the rows then you can try this. The xml where you create the layout of individual row for the ListView should be made a LinearLayout having two rows. ListView will create the rest of the rows for you by appending this LinearLayout.
Solution 2:
If each row is completely different from other (in terms of views used) then I would suggest using pagination. Divide your form questions into different relevant groups put each group on one page (scrollview). When user answers a set they have to navigate to the next page and so on.
As suggested by #Xaver Kapeller, I'd also suggest not using EditText in a ListView. It is very painful to debug keyboard issues and when the device orientation changes with keyboard open then as well. Instead of EditText ,use TextView which on tapping opens a Dialog box with a EditText. To keep the user interaction minimum.
You can focus the EditText as soon as the dialog open so that keyboard opens and user does not have to tap on the EditText. You can also dismiss the dialog by pressing the imeAction like Done on the soft keyboard or by pressing the hard back button. Dismissing the dialog should trigger a textview.setText("Data entered in the dialog box").

Detecting click event on a particular text in TextView with marquee

I am setting a text in textview.And it is marquee text.Not just the text, it is an array of text concatenated one after another and added to textview.I want that if i will click any text then that text(or word) will be shown in a dialog box.First of all is it Possible anyhow.I tried to use Spannable from this link first answer.but it's not working as per my requirement as i have marqueeing text.
Why wouldn't you replace the marque with something more useful? :) You may wrap your textView into a horizontal scroll view. Then you have a thread (AsyncTask) that scrolls the text, using ScrollView.setScrollX() just as marquee does.
Can you guess, what comes next? Use spans, as suggested by the link, you quoted!

Textview Click Issue Android

I have a textview as "emy wattson is a student" and I used marquee property for this textview. Now, it is sliding text. Now, I want to know the clicked word. For example, now I can click the all text and when I want to write the clicked text, I see "emy wattson is a student". But I want to know "emy" , "wattson" , "is" ... seperatly. So, how can I click just word???? Please,help me.
Hmmm...I'm not sure how this would be done. Since a TextView is just an instance of a String, the only way(that I know of) to extract specific values and indexes from String is to use indexOf() and subString() methods. What are you trying to do after you've determined which word in the TextView was clicked?

Edit Text which gives suggestions from the list view under it

In my Android app, I have this screen where the top part is a search box kind of thing and below it there is a ListView. Now the requirement is that when a user starts typing something in the search box I have push up items from the list view which match that pattern.
I have thought of using Auto Complete TextView, but that does not help because the items displayed must be in the list view itself where they can be clicked. They just need to be pushed up the list when they match the pattern of text typed in the Search box above.
How to achieve this ?
Please Help.
use addTextChangedListener in EditText to get user interactin with EditText and update the ListVIew using notifyDataSetChanged();. Try to use Handler

Measure text length before rendering

I have a widget where I need to display some text on one row. If the text does not fit, I would like to show as much as possible and end the text with "..." to show that not all text is displayed. Is there a way to discover how long the displayed text will be before rendering the widget, so that I can replace the last part of the text with "..."?
Cheers,
You don't need to do that - a TextView can do it for you.
myTextView.setSingleLine(true);
myTextView.setEllipsize(TextView.TruncateAt.END);

Categories

Resources