How to know clicked widget id?

后端 未结 2 852
不知归路
不知归路 2021-01-15 06:30

I have implemented a widget with an ImageButton and a TextView. That ImageButton launch an activity when its

相关标签:
2条回答
  • 2021-01-15 07:04

    For a running example have a look at my code for MiniCallWidget lines 97 and 169.

    0 讨论(0)
  • 2021-01-15 07:14

    Add an Extra to the intent you launch onClick and create in the for loop that specifies the ID of the current widget being setup.

    Then retrieve the ID from the extras in the receiving Activity, and pass it back when you're done. Then use the returned ID to make changes only to one widget.

    You can do this by having an if-else that also checks for a flag that tells whether or not you're updating only one widget.

    0 讨论(0)
提交回复
热议问题