【问题标题】:Detect OnTouch on AppWidget. If is it possible?在 AppWidget 上检测 OnTouch。如果有可能吗?
【发布时间】:2012-07-18 13:47:47
【问题描述】:

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

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

  • 模拟时钟
  • 按钮
  • 天文钟
  • 图像按钮
  • 图像视图
  • 进度条
  • 文本视图
  • ViewFlipper
  • 列表视图
  • 网格视图
  • 堆栈视图
  • AdapterViewFlipper

但是它们不符合我的需要。我用谷歌搜索了这个,但找不到任何可以帮助我的东西。 有什么方法可以在 AppWidget 中检测 OnTouch?也许这需要我拥有更新的 API 版本。

【问题讨论】:

    标签: android android-appwidget touch-event ontouchlistener


    【解决方案1】:

    似乎没有办法检测到AppWidget上的触摸。RemoteViews 没有办法检测到它(我们无法为它们注册触摸监听器)。

    Mark Murphy(CommonsWare) 在detect onTouch for widget 中说:

    您没有检测到应用小部件的“触摸式”。但是,您可以检测 点击,通过 RemoteViews 上的 setOnClickPendingIntent()。 AFAIK,这个 适用于 RemoteViews 支持的所有 View 类。

    另外,您不能在Android2.1 的AppWidgets 中使用StackView(参见simulate stack view in Android2(API 5)?)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 2013-07-23
      • 2012-10-08
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      相关资源
      最近更新 更多