【问题标题】:How to accomplish Android Widget with multiple ImageView each with multiple onClick Listener?如何使用多个 ImageView 完成 Android Widget,每个 ImageView 都有多个 onClick 侦听器?
【发布时间】:2012-05-08 17:11:39
【问题描述】:

我是 Android 开发的新手。 我在这里遇到问题,希望有人可以帮助我。

在小部件上,假设它有 3 个组件,即 ImageViews。

  • 我想要的是当用户点击 ImageViewOne,PendingIntentOne 将用户带到 ClassOne。
  • 当用户点击 ImageViewTwo 时, PendingIntentTwo 将用户带到 ClassTwo。
  • 当用户点击 ImageViewThree、PendingIntentThree 将用户带到 ClassThree。

如何做到这一点? 目前我只能为整个小部件设置 1 个 PendingIntent。


没关系,我已经知道了 感谢https://stackoverflow.com/questions/10081818/how-to-make-several-buttons-in-widget-send-broadcast-to-the-same-widget

【问题讨论】:

    标签: android onclick widget android-pendingintent


    【解决方案1】:

    为什么你只有 1 个 pendingIntent ?

    Intent intentLogo = new Intent(context, MainActivity.class);
    Bundle extrasLogo = new Bundle();
    intentLogo.putExtras(extrasLogo);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, Widget.REQUEST_CODE, intentLogo, Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent2 = PendingIntent.getActivity(context, Widget.REQUEST_CODE, intentLogo, Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent3 = PendingIntent.getActivity(context, Widget.REQUEST_CODE, intentLogo, Intent.FLAG_ACTIVITY_NEW_TASK);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 2011-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多