Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ODG - Android Touch Feedback: Click listener abbreviation
// Pass method
layoutName.setOnClickListener(onItemClicked);
private View.OnClickListener onItemClicked = view → // Do something;
// Or
private View.OnClickListener onItemClicked =
view → {
// Do something;
};
// Pass method with 'this'
layoutName.setOnClickListener(this::onItemClicked)
private void onItemClicked(View v) {
// Do something
}
// Pass method without view
layoutName.setOnClickListener(v → onItemClicked())
// Or
layoutName.setOnClickListener(v → {
onItemClicked()
});
private void onItemClicked() {
// Do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment