Advertisement
Guest User

Untitled

a guest
Feb 24th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. class OnClickConverter implements View.OnFocusChangeListener {
  2.     Runnable onClickAction;
  3.  
  4.     public OnClickConverter(Runnable onClickAction) {
  5.         this.onClickAction = onClickAction;
  6.     }
  7.  
  8.     @Override
  9.     public void onFocusChange(View v, boolean hasFocus) {
  10.         if (hasFocus) {
  11.             Button buttonConvertSpeed = (Button) rootView.findViewById(R.id.buttonConvertSpeed);
  12.             buttonConvertSpeed.setOnClickListener(new View.OnClickListener() {
  13.                 @Override
  14.                 public void onClick(View v) {
  15.                     onClickAction.run();
  16.                 }
  17.             });
  18.         }
  19.     }
  20. }
  21.  
  22. ...
  23.  
  24. editKnot.setOnFocusChangeListener(new OnClickConverter(new Runnable() {
  25.     @Override
  26.     public void run() {
  27.         // Custom logic goes here.
  28.     }
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement