0

I have a layout with 10 small EditText', each taking one digit. These fields need a custom focushandler, but how do I apply it to them all without writing the same class more than once?

Is there something like css select by class? Or some other way to do it?

If it matters, this is the focushandler I want to try: Moving focus from one EditText to another

As you can see, this uses findById, which I assume cannot do what I want.

Community
  • 1
  • 1
Mathias Nielsen
  • 1,560
  • 1
  • 17
  • 31

1 Answers1

0

You can make one class which implements OnFocusChangeListener like

public class MyFocusHandler implements OnFocusChangeListener
{
     private Context context;
     private Edittext edtext;
     public MyFocusHandler (Context context,EditText edText)
     {
         this.context=context;
         this.edText=edText;
     }
    // Override necessary methods.
}
Hardik Trivedi
  • 5,677
  • 5
  • 31
  • 51