问题
I have a Google Glass app that uses a CardScrollView
to display a series of Cards.
Touch gestures work to move between cards, but I need to be able to jump to specific cards by their index. I want to use contextual voice commands (ignore its limitations for now) to do this, for example: "ok glass, go to card 25".
I was hoping to be able to do something like this...
CardScrollView mCardScrollView = new CardScrollView(this);
// ...
// "ok glass, go to card 25"
// ...
mCardScrollView.setFocus(25);
...But I can't seem to find a function to do that.
I didn't find anything on Google's reference page: https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/widget/CardScrollView
And their sample code doesn't cover this either:
https://developers.google.com/glass/develop/gdk/ui-widgets#scrolling_cards_in_activities
I'd like to keep using CardScrollView
if possible because I like the way it animates and scrolls compared to ViewFlipper
or ViewPager
. It's such a simple functionality that I believe should be there. Perhaps I'm missing something?
回答1:
I was just having a similar issue. I was able to use mCardScrollView.setSelection(cardPosition) and it worked for m
来源:https://stackoverflow.com/questions/24922721/google-glass-jump-to-a-card-in-cardscrollview