I have a set of items which should be populated in the list, for that I have used WearableRecyclerView
. In some cases I want particular items to be in focus for selection. I am using scrollToPosition()
method of WearableLinearLayoutManager
but watch list do not scroll to the desired position, But the same thing on a mobile phone using RecyclerView
and scrollToPosition()
of LinearLayoutManager
which is set to the RecyclerView
working and scrolling to the desired position.
My code for wear watch:
WearableRecyclerView slots_rv = findViewById(R.id.slots_rv);
.....
WearableLinearLayoutManager wearableLinearLayoutManager =
new WearableLinearLayoutManager(this, customScrollingLayoutCallback);
slots_rv.setLayoutManager(
wearableLinearLayoutManager);
slots_rv.setCircularScrollingGestureEnabled(true);
wearableLinearLayoutManager.scrollToPosition(slotsAdapter.getPositionToFocus());
slots_rv.scrollToPosition(slotsAdapter.getPositionToFocus());
slots_rv.getLayoutManager().scrollToPosition(slotsAdapter.getPositionToFocus());
slots_rv.setAdapter(slotsAdapter);
What may go wrong here?
Looks like you're not using the WearableLinearLayoutManager you declared in the 2nd line. You're setting the LayoutManager to a new instance so calling scrollToPosition won't work. Try the following
WearableLinearLayoutManager wearableLinearLayoutManager = new WearableLinearLayoutManager(this, customScrollingLayoutCallback);
slots_rv.setLayoutManager(wearableLinearLayoutManager);
slots_rv.setCircularScrollingGestureEnabled(true);
wearableLinearLayoutManager.scrollToPosition(slotsAdapter.getPositionToFocus());
slots_rv.setAdapter(slotsAdapter);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With