问题
I am using a cardscrollview in an Activity to show text and pitcures on different cards.
Today i can scroll by using touchpad and swipe left or right but i want to scroll between cards using voice.
Example : when i say "next" i would like to scroll forward, and when i say "prev" i would like to scroll backwards.
I saw different answers on stackoverflow like this one or this one and it looks like you can't include GlassVoice.jar anymore (tried it but not working). I saw on google documentation that i could use Contextual voice commands but i don't really understand how to include it for my case.
I would like to have something like that :
if(voicetrigger == "next"){
scrollForward();
}
Do you think it's possible to do ? I would be grateful if someone could help me or have ideas to make it work.
Thanks
回答1:
Implement contextual voice commands with menu items such as "Next" and "Previous." Once one of those items is triggered, call setSelection(int position)
on your CardScrollView with the parameter being either the current position + 1 or -1.
Here's a sample of how I use that method in my onMenuItemSelected
:
mCardScroller.setSelection(mCardScroller.getSelectedItemPosition() + 1);
来源:https://stackoverflow.com/questions/29280000/google-glass-android-how-can-i-use-voice-trigger-from-current-activity-to-swi