Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
RecyclerView focus orientation
fun RecyclerView.getViewByPosition(position: Int): View? {
return findViewHolderForAdapterPosition(position)?.itemView
fun RecyclerView.fetchViewAt(position: Int, callback: (View?) -> Unit) {
post { callback(getViewByPosition(position)) }
fun RecyclerView.focusChildAtPosition(position: Int, success: (Boolean) -> Unit = {}) {
fetchViewAt(position) {
success(it?.requestFocus() == true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.