views:

124

answers:

1

I have a custom EditText and a TextView in an Activity. The custom EditText traps for key presses and calculates the number of character entered and wants to publish the character count to the TextView. Do I use the java.util.Observable/Observer way ? Or is there a more native android method to achive this ? Thanks.

+2  A: 

Observable/Observer is probably fine in the abstract.

For EditText/TextView, you could use addTextWatcher() rather than subclassing EditText to support your character count.

And bear in mind that you should really test this stuff with the soft keyboard, as I am under the impression that per-keystroke event behavior changes when users use the soft keyboard instead of the G1's QWERTY keyboard.

CommonsWare
Hah! You're too late. I already am subclassing EditText. :) I will investigate the TextWatcher method.
Jacques René Mesrine