是Android应用程序的小部件(对于主屏幕)允许的手势? [英] Are Android app widgets (for home screen) allowed gestures?

查看:213
本文介绍了是Android应用程序的小部件(对于主屏幕)允许的手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当我刷我的手指从左跨主屏幕小部件的权利,在模拟器上AVD,Android的切换到左侧主屏幕。

I noticed that when I swipe my finger from left to right across a home screen widget, in simulator on a AVD, Android switch to the left home screen.

我在想,如果可能的prevent这种行为,让主屏幕小工具聆听和响应指手势(如刷卡)?它非常重要的我的小部件的UI设计。

I was wondering if its possible to prevent this behavior and allow home screen gadgets to listen and react to finger gestures (like swipe)? Its very critical for my widget UI design.

推荐答案

与API级别11开始(的Andr​​oid 3.0.x的),你可以使用 android.widget.RemoteViewsService.RemoteViewsFactory ,并与分配一个小部件来使用(从文档):

Starting with API level 11 (Android 3.0.x) you can use "android.widget.RemoteViewsService.RemoteViewsFactory" and and assign a widget to use (from docs):

的ListView 的:一个视图,显示了垂直滚动列表项。举一个例子,看看Gmail应用程序部件。

ListView: A view that shows items in a vertically scrolling list. For an example, see the Gmail app widget.

的GridView 的:一个视图,显示在二维滚动网格项目。举一个例子,看到书签应用小工具。

GridView: A view that shows items in two-dimensional scrolling grid. For an example, see the Bookmarks app widget.

StackView 的:一个叠卡片视图(有点像一个关系网),在这里用户可以轻弹前插卡向上/向下看previous /忘词,分别。例子包括YouTube和书籍的应用程序部件。

StackView: A stacked card view (kind of like a rolodex), where the user can flick the front card up/down to see the previous/next card, respectively. Examples include the YouTube and Books app widgets.

请参阅<一href="http://developer.android.com/guide/topics/appwidgets/index.html">http://developer.android.com/guide/topics/appwidgets/index.html部分使用App小部件集合。

See http://developer.android.com/guide/topics/appwidgets/index.html section Using App Widgets with Collections.

所以,是的 - 如果你使用上面的布局之一小部件会接受手势

So yes - if you use one of the above layouts your widget will accept gestures.

这篇关于是Android应用程序的小部件(对于主屏幕)允许的手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆