Google Glass - 'Jump' to a card in CardScrollView?

故事扮演 提交于 2019-12-14 03:58:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!