Gowtham
Gowtham

Reputation: 197

Does proteus support onKey up/down events

I wanted to get information on the page created using proteus, like the key events that user does with some remote controls.

Is there a possibility to get onKeyUp or onKeyDown events like native code.

onKeyUp(final int keyCode, final KeyEvent event)

Upvotes: 2

Views: 63

Answers (1)

vader
vader

Reputation: 909

You could find the view by it's id and use the Android view anyway you want.

 /*
  LAYOUT:
  {
    "type": "TextView",
    "id": "some-id"
    "singleLine": "@bool/true",
    "text": "TextView",
    "textColor": "#000000",
    "textSize": "12sp"
  }
 */
view = layoutInflater.inflate(layout, data, container, 0);
View tv = view.getViewManager().findViewById("some-id");  // See the layout above
assert tv != null; // this is nullable
tv.setOnKeyListener(new View.OnKeyListener() {
  @Override
  public boolean onKey(View v, int keyCode, KeyEvent event) {
    // do something.
    return false;
  }
});

Upvotes: 1

Related Questions