Is it Possible to Display some text say a story, in an ANDROID app which also enables the user to select some text and perform some operations on that text..
the main idea is to display some text and when the user selects some text(a word or a sentence) i need to get that text for some further operation on that text.
we cant use text view as you cant select text in textview,and we cant use editview because the user should not be able to edit the contents of the text.
Why not display the text in a WebView and enable text selection?
It works pretty well in CodePad, which is open source so you can have a look at the code here.
My first try would be to display this text in a normal TextView. Then I would provide two or three buttons to implement the selection of a part of the text. For example 1 Button to start and end selection and 2 Buttons with arrows for increasing/decreasing the part of the selection.
To highlight the part of the text which is selected, I would for example color this part of the text in a different color.
Coloring of text can be either done by using Spannable or the HTML class.
Related
I have textview in which multiple links are shown, the text is dynamic.
I have added following to textview
android:autoLink="all"
android:textColorLink="#color/selector_autolink_textcolor"
This makes all links in textview show a different color and show click color, but on click of textview all the links in textview show selected color, this confuses the user as he cannot identify what he's clicking.
How can I only highlight/show press-state of a single link when pressed.
I have two approaches for you to solve this problem.
First Approach:- This one is quite simple. You can use different TextView to display hyperlinks and display the links. On clicking them you can get different selector color
Second Approach:- Use can use Spannable concept in Android to achieve this. Break the string into different part to show different hyper links. You can achieve the different color slector based upon user click. You can follow this example more from here (see try Spannable part) Change the text color of a single ClickableSpan when pressed without affecting other ClickableSpans in the same TextView
I am using MultiAutoCompleteTextView.
When I select any item from a drop down then it displays in the MultiAutoCompleteTextView after I put some text in it. Adding some text after, I select a username from the auto complete and it comes in below the line I want it to.
I would like to get the text in the line with MultiAutoCompleteTextView having enough space to show it.
I am using MuPdf to display pdf file and its successfully implemented but now i want to get selected (highlighted) text?
Thanks in Advance.
Seems to me you have 2 problems, the first is to extract the text, which MuPDF can already do. There is example code for this I believe. Then you need to compare the co-ordinates of the highlighted area with the position of the text, and decide which text is within the highlighted area.
So the first part you have example code for, the second part is up to you, as its (presumably) your application that draws the highlight. THe last part is then your job, figure out which text is within the area.
I have successfully created a custom key pad in my application but i am unable to find out how to display a dictionary of words like android default keypad which appear at the top whenever we type.
1st you need to take an AutoComplete TextView
Afterwards , you need to follow this example:
Creating a Search Interface
In this example the ListView's Data-Source is being changed when the text is entered in Search Bar.You need to change the Data-Source of AutoComplete TextView as the user enters different texts.
I hope this will solve your problem.
I am developing an Android application and I have displayed a story using TextView. I want that if the user tap on a particular word, it will copy that word and send it to the dictionary within the application and search for its definition. How do I do that? How do I know what word is tapped by the user since the TextView consists of around hundred words.
In same case I used array of textViews. To make it this way you should prepare text, for example split text with " ".
The second way is to use WebView, text as html doc and some javascript.