i want to select some part of the text from text view using long press and drag. Basically am looking for a functionality like android pdf reader text selection. how can i implement this? after select some text i need to highlight it (color change/underline etc) .When i again visit the same page, app should show the content like i previously highlighted.
I saw the textview.setTextIsSelectable(true) option,
when i use this i can select the text, whats next? is this the proper method for this kind of task ? please help.
You should use
textView.setSelection(startIndex, endIndex);
instead
Related
As you can see in the title i dont know how to make a java text field with text in the background that disappears when you click on it.
So theres a textfield that says "username" and when u click on it the username disapears and you can type in your password. Is it possible to do this without a new class?
my suggestion is to use swingx library and use JXTextField. so you can set the text using setPrompt method.
I'm using "Flow Text View" to wrap my text around a picture.
But them problem is, I'm using Persian language so I have to set text direction to "RTL" but have no idea how to do it for the Flow Text View.
Here is a picture of how my texts get while direction is LTR...
I hope to help me how to set direction to rtl, I will provide any code you need and I will answer immediately.
I have a Java Swing application that has various screens / tabs from 1 to 8. There are series of selections and Text Inputs in each tab and in the final tab, I have a button to create a text file based on the selections the user has done. The text file should be formed in a formatted manner and that will be defined in the code. I would like to understand if there is a way to do this, other than defining each selection / control in the application to a corresponding text segment using FileWriter or anything similar.
Example:
In Screen 1:
User Selects "Radio 1" and Enters Text "Godzilla"
When in the button click, I need to create a text file suitably in this format.
Screen 1 {
Best Movie : Godzilla
}
Thank You in advance.
This looks exactly like JSON! Check it out here: http://www.json.org/java/
It is formatted exactly the same way your example is! :)
I looked on google but didn't find what exactly i am looking for.
I want a edit text to have text or image which i can change by tapping it and selecting new text or image. Also i want hint followed by that text or image.
I tried multiple experiment and was able to add text(by changing selection location and adding text) and image(using drawable addition from android code)
For text :
edt.setText("Fixed Text");
Selection.setSelection(edt.getText(), edt.getText().length());
Image through XML:
android:drawableLeft="#drawable/ic_launcher"
But when i add text, i won't be able to add hint. In case of image hints get added. Also i want my permanent text and image to be tappable and updatable.
Any help would be really helpful. I want $ to be fixed and tappable, and want to change it to different currency. but want 52.63 to be hint and can be editable by user tap.
EDIT to give more clarity:
Example: i want to add part of the text as permanent and part as hint for example $ 52, so $ is permanent and not editable through user, he can select it through list view by tapping on $, but 52 he can change using android keyboard.
I am not quite sure about the whole part about the image being placed into the EditText as a hint, but if you wanted to create the $52.63 as a hint in the EditText, all you would have to do is:
edt.setHint("$52.63");
in your onCreate() method. I am not sure if this is what you are looking for, but this is a simple way to add a hint to a textEdit. If you wanted the hint to change when the user tapped the screen or something like that, I would look into adding a tap listener of the android component that you desire to be tapped to change the hint, and then modify the hint using the method above.
I am developing a project in which i'm displaying certain checkboxes to user that he may select a few of them as his/her seat as in movie hall or airplane. I want checkbox to be displayed as chairs or some other image how can i do it. The generation of checkboxes is happening in custom tag (java web project)
Please go thro the HTML from below URL. Here background images are applied to checkboxes.
http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/demo.html
You may also use the same logic, have two images. One is for before select, during onclick change the another background image.
If you want to do this then u should write a custom java script code for this purpose.
Create image and then associate the states (true / false) with them and when user perform the select(Click) operation on those image then change the state associated with Image.
Here is a link from where u can learn how to implement this
http://homepage.ntlworld.com/vwphillips/ImageCheckBox/ImageCheckBox.htm