-3

for instance, add double tap listener for VideoView. I hope it support following code:

//Player.kt
var vv = findViewById(R.id.player) as VideoView
vv.onDoubleClick {
  // do something
}
thanksd
  • 54,176
  • 22
  • 157
  • 150
pozklundw
  • 505
  • 1
  • 9
  • 16
  • Did you checked this code to work in IDE? Did it work? Can't see a problem here. Please clarify what you are asking. – voddan Jan 17 '16 at 05:55
  • @voddan, it's ok code, I just wanna know how to customize view listener – pozklundw Jan 17 '16 at 06:00
  • 1
    Sorry, I still do not follow you. Could you please modify the question? – voddan Jan 17 '16 at 06:04
  • 1
    What are you trying to do? What have you tried (code)? What was wrong about the result that you want help with? Did you receive a specific error? – Jayson Minard Jan 18 '16 at 12:58

1 Answers1

2

I hope it support following code:
...

Most likely the syntax that you've shown here is inspired by Anko library which has some extension functions allowing you to add the View listeners in this pretty fashion:

button.onClick {
    Toast.makeText(this, "Hi there!", Toast.LENGTH_SHORT);
}

instead of wordy Java syntax:

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(this, "Hi there!", Toast.LENGTH_LONG).show();
    }
});

Unfortunately, Anko doesn't have the onDoubleClick extension function (well, the View doesn't have the setOnDoubleClickListener() method, either). If you want to add double-click support to your views, you need to use GestureDetectors. And, if you wish to write this code with the help of extensions functions, like in Anko, documentation can be found here.

Community
  • 1
  • 1
aga
  • 27,954
  • 13
  • 86
  • 121