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
}
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
}
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.