tags:

views:

38

answers:

3

I'm new to android programming, and I was wondering if there was an event or something for any virtual keyboard input. I was also wondering if there is an event for when you try to send a text message, or maybe a way to send a text message. I want to use 2.2. thanks.

After doing some reading it looks like this isn't possible. What I wanted to do was globally catch keys from the virtual keyboard.

A: 

If you have an EditText and want to catch characters typed into it from the virtual keyboard you can use a TextWatcher. Below is an example how to update a character counter:

edittext.addTextChangedListener(new TextWatcher() {
  @Override
  public void onTextChanged(CharSequence s, int start, int before, int count) { }
  @Override
  public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
  @Override
  public void afterTextChanged(Editable s) {  
    /* get text length and update the counter */
    counter.update(s.length());
  }
});
JBM
A: 

You can use either a TextWatcher or a KeyListener to react on button events. Whereas the TextWatcher doesn't react on key events it rather reacts whenever the text of an EditText control changes. So it depends on you needs which way you go.

Regarding your question about the text messages I think this question will should help you understanding how to send an text message.

Flo