Tutorial :What is the native way of implementing Publish Subscribe between Android widgets?



Question:

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. Should I use the java.util.Observable/Observer way? Or is there a more native android method to achive this?


Solution:1

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »