I have a problem: I have a text in a TextView in an android application. The users shall search a word in this text with an EditText and a button and the view should go to the word that is found and mark it. If there are more search solutions than one, it should be possible that the user can click on a 'Next' button and the next word that is found should be shown.
It's very important.
Does anybody know how to code this? THANKS for help!
you can get searching text from user using toolbar search view and then apply search with String.indexOf() then highlight result via SpannableString class
Related
Even a Snippet of an android code to Integrate Google Search into an Edit text will be really useful, according to my requirement i don't want the google search data or whatever but only the dropdown so that it will b easier for people to type and don't have to waste time :)
You can see about the componenent is AutoCompleteTextView
An editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
I would like to create a book reader and for this i have a problem of selecting some text and i don't know what is the best way. I read some posts in which they where using EditText for selection. But this is not so usefull because when you long tap it shows select word/select all and the keyboard appears, what i want is only the possibility to select text, listen the selection and then using Spannable/Linkify to edit that portion of text.
If there is no easy thing to use the standard text cursor controllers, can i create a custom cursor controllers or something like that ?
I read this posts:
Select text from TextView?
How to allow the user to select a text range in a TextView (Similar to EditText)
Thank you in advance.
Update:
I found this class android.text.Selection that seems to use the cursor controllers But i don't find any examples on google about it.
Use android:textIsSelectable="true" on your TextView.
I'm made a custom TextView with selection capability by studying Android's source code.
Please see my answer from the other question Android- How can I show text selection on textview?
I like to recreate the behaviour of the textview containing the message of a user in the g+-app in my android project. To be exact:
- on click on a link the link is visually selected (blue selector) and will open up in the browser
- on click on normal text the whole list item is selected
The main problem I have, is, that every approach I tried to make links clickable (via xml and autolink=web, or in code) ends up, that the link opens up in a browser on click, but when I touch normal text in this textview the item is not selected (no selector is visible).
I read many threads about this issue, but all the solutions, like add setFocusable(false), etc. doesn't work for me.
So I want to ask, if there is any tutorial, how to or example, where I can see how this things work, or do you have any idea how I can get it to work?
Thanks! :)
if you have email id in textview use below code..
TextView email = (TextView)findViewById(R.id.TextView04);
email.setText("sasd asd#gmai.com sadasd");
email.setLinkTextColor(Color.WHITE);
Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES);
if you have url in textview use below code...
TextView tv = (TextView)findViewById(R.id.TextView04);
tv.setText("sasd https://asd.com sadasd");
tv.setLinkTextColor(Color.WHITE);
Linkify.addLinks(tv,Linkify.WEB_URLS);
I see that after android 3.0 it introduce into the isselectable attribute, but i found even in android 2.1, the SMS editbox can allow user double click a word you typed and highlight to select it. how does it work? i thought it's a regular edittext box but it's not. the layout edittext box can't doubleclick and select a single word, it can just press and drag to select, and it works very bad.
so, does anyone know how to implement this: when i double click(or long click) a word of the text in TextView(or any other view), the word can be selected and i can perform some actions.
who knows how the SMS editing box implement?
thanks.
I did answer a (somehow) similar question here. The solutions should work from Android 1.5
But this works with the "mark some text"-solution. Maybe it's helpful anyways.
What type of textview should I use so that everytime i touch it, it will display the most recent entries used in a dropdown box? AutoComplete and MultiAutoComplete are confusing to me...
Thank you
Auto Complete Tutorial will help you. If user writes something to textView and submit it, then you can save this string to a file. And if you add this to the string array which mentioned in tutorial, auto complete dropdown will appear...