views:

154

answers:

2

I'm new to Android development and I can't seem to find a good guide on how to use an onKeyUp listener.

In my app, I have a big EditText, when someone presses and releases a key in that EditText I want to call a function that will perform regular expressions in that EditText.

I don't know how I'd use the onKeyUp. Could someone please show me how?

Please & thanks, Alex.

A: 

Just for an EditText. its achieve by setOnClickListener() itself. No Need for the onKeyUp(). Because that will perform by a click/Touch Event. right? Just do this.

edittext_object.setOnClickListener(new OnClickListener() {
     public void onClick(View v) {
    //do what you need 
    }
}
Praveen Chandrasekaran
A: 

Writing this out of my head but it should be among the following lines:

text.setKeyListener(new KeyListener() {
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {


        if(keyCode == KeyEvent.KEYCODE_0) dosomething // pick the custom key from keyEvent


        return super.onKeyUp(keyCode, event);
    }
});
Milan