How to use getSelectionStart and getSelectionEnd of TextViewwhen user touches? - android

I want get text like phone number inside a textView by parcing, and i want use this getSelectionStart(), but it dosen't work?? can someone give me an example please.

I made a bad first answer because I mixed getselection with the new text api of 2.3.
You will find some answer in those thread :
Android - get selection of text from EditText
How to use getSelectionStart and getSelectionEnd of EditText when user touches EditText?

Related

AutoFill EditText Android

I'm trying to create a search bar like.
I have to use a particular autofill, infact I can't use a dropdowns menu.
For example if I write Noce the edittext will have to suggest Nocera in the same editText, like this.
but if the user write something else the pointer have to the end of the typed text (in this case Noce) and the hint have to disappear.
Is there some library that allows me this?
Thanks for the help.
There's this library that will fulfill some of your requirement called Auto Fill EditText
Finally I have solved this using two EditText in the same position. The first one is a normal editable EditText, the second one is not editable from the user but is used to show the hints programmatically.

Android how to get Suggested strings array of the TextEdit

Is there a way to get an array of the suggestions strings which are shown when you typing in EditText? The problem is I have an EditText and in case of user use "Show Suggestions" option the result of the string from this EditText is different in case of user pressed, lets say UI button (this is a Button from the layout), and a return button at the soft keyboard. In first case user gets an exact string but in second - it gets corrected (suggested) string even user do NOT select this suggestion. How to solve this problem? How to get from EditText "suggested" string? Do I need to implement my own IME?
Maybe this can help you ? Hello Auto Complete
Or if you want to write one on your own.. Writing your own autocompleteview
Are you trying to disable suggestions or to modify them?
If you want to disable them completely, check this out:
How to disable displaying "suggestions" on the Soft Keyboard

TextView can be edited?

I have simple question. I am a new newbie to android. I did got through few tutorials but some responses did not work in my eclipse. I am using version 2.2.
Can we give text view the functionality of edit text of editing?
EditText extends TextView and gives it editable functionality, if you want the EditText to look like TextView, You can change the background and other style properties
User won't be able to type or edit anything in a text view. It is purely for viewing. But you could set values in a text view with user inputs from an edit text.
TextView
Displays text to the user and optionally allows them to edit it. A
TextView is a complete text editor, however the basic class is
configured to not allow editing; see EditText for a subclass that
configures the text view for editing.
You can use EditText for this.
Yes you can make Textview editable, with android:editable="true",
Please check this link for further reference..
http://developer.android.com/reference/android/widget/TextView.html#attr_android:editable
Hope this will help you
Yes, TextView can be edited. Try this:
TextView.setText();

AutoCompleteTextView hide auto complete suggestions

i have an AutoCompleteTextView widget on the view. if it has input focus and I'm trying to change the text in there with:
txtField1.setText("test");
I'm getting suggestions list appears on the screen. How do I hide it? is it possible to update the text not showing suggestions?
I'll leave this here, in case someone needs it in the future, like I did.
yourAutoCompleteTextView.dismissDropDown();
will make the list with suggestions disappear from the screen.
I suggest some methods
1)If you want to make "test" like hint of autocomplete textView then do like this,
txtField1.setHint("test");
2)If you need to fill up the text view with "test" and also need to prevent the suggestion increase the threshold level for auto complete textview ,
txtField1.setThreshold(5);
if you use threshold it will show suggestion after 5 character (according to the code posted in above line). If you need try to set different word and also try to avoid suggestion , change the threshold dynamically based on length of string.

Edit text view issue

Hi friends
I have an editable text box with a default value like to display to the user like "entername". If the user touches the edit box, I want to clear the value of edittext box and show the virtual keypad to the user, and if the user presses the enter key, only in the edit text box, I have to start another activity. How do I do this?
Hi in android:hint at the type of key pressing only it clear value I want to on touch in edit text box clear value and show virtual keypad to user. How do I do this?
Thanks
What?
I really don't understand what you're asking, but it seems like you might be trying to do a hint? Rather than setting an onTouchEvent listener, add a android:hint="What to do" attribute to your EditText.
U use the following code
EditText EditTextName=findViewById(R.id.EditText01);
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(EditTextName), 0);
use this code in ontouchListener of EditText
Mohan if I am correct you have two questions here
How to display a hint in an edit box
How get some data from a web service
For the first question you can use android:hint="Enter Name"
For the second one you need to give us more info on what you are trying to do

Categories

Resources