在AppWidget上检测OnTouch.如果有可能吗? [英] Detect OnTouch on AppWidget. If is it possible?

查看:138
本文介绍了在AppWidget上检测OnTouch.如果有可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AppWidget上检测OnTouch.如果有可能吗? 你好!我正在尝试为Android 2.1创建我的第一个AppWidget,其中客户端可能有机会在我的自定义视图中选择一个项目.我将创建一个自定义视图和一个滑块,客户端可以通过在自定义视图上拉动滑块来进行选择.为此,我想检测AppWidget的onTouch(以确定X,Y坐标),有没有办法做到这一点?

我看到了可以在AppWidget中使用的有效窗口小部件的列表:

  • AnalogClock
  • 按钮
  • 天文钟
  • ImageButton
  • ImageView
  • ProgressBar
  • TextView
  • ViewFlipper
  • ListView
  • GridView
  • StackView
  • AdapterViewFlipper

但是它们不符合我的需求.我已经用谷歌搜索了,但是什么也找不到可以帮助我的. 有什么方法可以检测AppWidget中的OnTouch吗?也许这将要求我拥有较新的API版本.

解决方案

似乎无法检测到AppWidget上的触摸.RemoteViews无法检测到它(我们无法为其注册触摸侦听器)

此外,您不能在Android2.1的AppWidgets中使用StackView(请参阅在Android2(API 5)中模拟堆栈视图?).

Detect OnTouch on AppWidget. If is it possible? Hello! I'm trying to create my first AppWidget for Android 2.1 in which a client may have a chance to select an item on my custom view. I'm going to create a custom view and a slider for it and client may select by pulling slider over the custom view. For this purpose I want to detect onTouch for AppWidget (to determine X-, Y- coordinates), is there way to do this?

I saw a list of valid widgets which can be used in AppWidget:

  • AnalogClock
  • Button
  • Chronometer
  • ImageButton
  • ImageView
  • ProgressBar
  • TextView
  • ViewFlipper
  • ListView
  • GridView
  • StackView
  • AdapterViewFlipper

However they do not fit my needs. I have Googled this but find nothing which could help me. IS there any way to detect OnTouch within an AppWidget? Perhaps this would require me to have a newer API version.

解决方案

It seems that there is no way to detect touch on AppWidget.RemoteViews have no method to detect it(we can not register a touch listener for them).

Mark Murphy(CommonsWare) in detect onTouch for widget says:

You don't detect "on touch" for app widgets. You can, however, detect clicks, via setOnClickPendingIntent() on RemoteViews. AFAIK, this works for all View classes supported by RemoteViews.

Also,you can not use StackView in AppWidgets in Android2.1 (see simulate stack view in Android2(API 5)?).

这篇关于在AppWidget上检测OnTouch.如果有可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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