Linus,

Have you considered using AutoCompleteTextView instead of an EditText?

It provides a ready-made infrastructure for autocomplete, and probably works on all devices.

-- Kostya

31.01.2011 16:04, LinusOnline пишет:
I'm struggling with some strange bahavior in EditText fields on the
Samsung Galaxy Tab and Samsung Galaxy S. Has anyone else experienced
similar behavior to this?

Situation:
I'm using an EditText as an input window for URLs. As the user enters
a character in it, I want to autocomplete it, i.e., look up the string
in a list of URLs, find the first match (if any), and change the
contents of the EditText to that URL, while keeping a selection around
the suggested part.

So, the sequence is:
1. User enters character (f.i. the 'c' in 'www.c').
2. onTextChanged is called, notifies my own thread, and returns
3. My own thread then posts a Runnable in which I do the following:
4. Using setText, I change the text to, i.e., www.cnn.com.
5. Using setSelection, I select the suggested part (i.e., 'nn.com')

Problem On Samsung Galaxy S (and possibly other Samsung devices),
using the Samsung IME:
It seems like every time a character is entered in the URL field, the
text it is set twice; once immediately, and then "magically" again a
few ms later. In the above case, the text gets reset to 'www.c'
*after* I've autocompleted it. Delaying the posting of the Runnable
which changes the text for a few (~10) ms (using postDelayed) works
around this.

Second problem, occurring so far on the Galaxy Tab and Galaxy S, and
only in landscape mode, when the IME is fullscreen, but with *any*
IME:
Even with the above workaround, the selection on the suggestion part
of the URL is cleared (while the actual text remains). This time, it
appears that the effect of the setText call in step 4 is repeated
(again, "magically") after about 100 ms. Using another call to
postDelayed, I can delay the call to setSelection a further 100 ms,
which again works around the problem.

Both workarounds are very ugly, timing-dependent solutions, and I'd
rather find a better one.

Usually, the magic text-set is accompanied by some nondescript lines
of logcat error output.

On the Galaxy Tab, using Samsung IME, I get this:
01-31 21:25:49.500: ERROR/AxT9IME(20639): WordSymbInit: 1
01-31 21:25:49.508: ERROR/KeyLedTest(20639): KeyLedTest++
01-31 21:25:49.508: ERROR/KeyBoardLed(19113): UpdateState../sys/class/
sec/keyboard/keyboard_led state false
01-31 21:25:49.512: ERROR/KeyBoardLed(19113): UpdateState../sys/class/
sec/keyboard/keyboard_led state false finished
01-31 21:25:49.512: ERROR/KeyLedTest(20639): service.UpdateState0
01-31 21:25:49.512: ERROR/InputMethodService(20639): Keyboard State :
0

With a different IME than Samsung's, I only get the last one of these
lines.

On Samsung Galaxy S, I only get an error when using Samsung's IME.
What I get is this:

01-31 12:22:14.622: ERROR/AxT9IME(2583): WordSymbInit: 1

Again, has anyone else experienced similar behavior to this?



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to