Detect OnTouch on AppWidget. If is it possible?

依然范特西╮ 提交于 2019-12-10 19:29:50

问题


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.


回答1:


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)?).



来源:https://stackoverflow.com/questions/11542916/detect-ontouch-on-appwidget-if-is-it-possible

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