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?
Related
I have 1 listView, items of listivew about : button translate, text translate.
when i click button translate,text translate success,(save object model). But error no change text had translate when scroll.I want save status click button translate when scroll again, it translate. can you help me? sorry my english.
Code : I remove code. sorry
At first, I want to clarify your issue:
you want tvTipsMessage update with translated text.
your code works when click in btnDrunkenTranslate but when you scroll down then scroll up again, tvTipsMessage display the untranslate text?
If those above is correct, then I think your problem is you aren't save the new translated text to your object model (although you said you do).
Your object model is FSTipModel, and you use item.getText() to get the display text. But from your posted code, I don't find any code update that value.
You may need to apply this:
add FSTipModel mItem; in ViewHolder
in ViewHolder.fillData, add mItem = item;
in onTranslateTipSuccess, replace tvTipsMessage.setText(CommonUtil.getStringData(data.getResult())); by
mItem.setText(data.getResult());
mText = mItem.getText();
tvTipsMessage.setText(CommonUtil.getStringData(mText));
Hope this works.
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!
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)
I am trying to build a calculator app. i use textview to recieve the value from button, whenever user click on button. but when user click on the button second time then the value in textview is overwritten by the value of the previous button.
But i want to get the whole value in textview.
Ex: Suppose user click on the 1 then 2,then 3 so number appear in textview will be 123.
So please guide me.
when user click on the button second time then the value in textview is overwritten by the value of the previous button
Use append() instead of setText() to add on to the existing string in your TextView.
To do this you need to add the number to the string in your textview, instead of replacing it. Put the following in you onClick method for each button
String s = textview.getText().toString();
textview.setText(s + "1")
I have a static radiogroup in my XML layout, but I have created all of the radiobuttons dynamically as an effect of user input. Since none of these have ID's, is there a way I can call a method on a whole radiogroup to just return the text (or label) of the checked radio button? All the labels are URL's so if I can get the URL of the checked radio button then I can pass it to a method i created to open the web browser.
I can use ID's but then I would have to create a bunch of extra text for the radio button labels anyways, then a bunch of if statements with the labels written a second time.. [ if this ID is selected go to this URL, if this ID is open go to this URL...] Where as I just want to take the RadioButton's label and just put it right into the browser method.
I found this post: Android: How to get text of dynamically created radio button selected by the user?
but it wasn't answered correctly.
Thanks in advance.
If IDs are no good for you, maybe you should use the tag property that all Views have, i.e. call radioButton.setTag(url) when you create the button. Then call View.getTag() in your onClickListener and cast to a String to get your URL back.