I have an object which stores start and end of the selection made on the textview earlier. I do it by textview.getSelectionStart() and textview.getSelectionEnd().
Now I am in another activity and I have this object and the same textview, I need to programmatically select the text again in order to edit the selection.(I have start and end of the previous selection).
Please help!
Related
I would like to know how to read the contents of a text file line by line and add it to a ListView in Android.
Look at my scenario:
I have three activities-add_new, show and show_all. In the "add_new" activity, there are two EditText fields and a button. When I enter text in both the EditText fields and press the button, it should be stored as two separate lines in a text file in the Android filesystem.
The "show_all" activity contains a ListView, which populates the contents of the text file in such a way that, the one line is shown as the title (the content read from the first EditText field) of each item, and the immediate next line (the data read from the second EditText field) is the data associated with it in the listview.
When I click any item in the ListView, a new activity, "show" displays the details ofthat particular item. When I press delete button in that activity, the original text file need to be updated in such a way that, the lines associated with that item need to be deleted.
How do we do this?
By an array, when I press a button show new text in a textview (scrollable).
So, if a read the text in a textview until half page and press the button, new textview show me new text NOT from start of it but with same position of last textview.
How I resolve this problem?
thanks!
Going to take a wild stab in the dark that when you mention scrolling text view, you are referring to a EditText view. If this is the case, you can set the position of the cursor in an EditText by using the setSelection function. To return to the start, you would use setSelection(0).
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 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?
I have a listview , on top of it there is a auto complete textview. Onclick of listview and autocomplete textview text ,it goes the detail activity. when back button is pressed,it comes from detail activity to list view page but the autocomplete textview contains same searched product term. How can i keep it empty so that it is ready to type(in stead of deleting it again and again)?
Thanks..
One way would be in your onResume() method in activity, get the reference to your AutoCompleteTextView and use setText() method to set text as empty. and use requestFocus() to give focus to AutocompleteTextview.