0

I'm considering make my own EditText for a Game with a personal appeareance.

As I see if I extend Edittext class, I have to override the onDraw method and make my own Canvas.

In the other side I have considered the option of make a CompoundView with elements to style that (is more easy to design with components already defined and used styles and XML to mockup)

My problem is, What's the method that is called by the IME when user enters a key???

Because I've tried to override all I see similar, but I can't manage it internally.

Thank you

pianista
  • 108
  • 8

2 Answers2

0

you can use setOnEditorActionListener. Like below

((EditText)findViewById(R.id.editText)).setOnEditorActionListener(
    new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEARCH ||
            actionId == EditorInfo.IME_ACTION_DONE ||
            event.getAction() == KeyEvent.ACTION_DOWN &&
            event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
        onSearchAction(v);
        return true;
    }
    return false;
 }
});
maddy d
  • 1,530
  • 2
  • 12
  • 23
  • Yes, I've thought about it, but It's strange that the class hasn't a method to manage this. If I don't find something better, I'll make something like this – pianista Apr 16 '14 at 09:57
0

Thanks to pskink I found this question related:

How to Capture soft keyboard input in a View?

It shows how to make your own view and catch the keyboard events internally in the view.

Thanks you all!!!!

Community
  • 1
  • 1
pianista
  • 108
  • 8