开发者

How to correctly handle click events on Widget

开发者 https://www.devze.com 2022-12-29 12:33 出处:网络
There is a task to make smt like todo list on widget (with dynamic number of elements), how to organize this list for click support on this elem开发者_C百科ents.

There is a task to make smt like todo list on widget (with dynamic number of elements), how to organize this list for click support on this elem开发者_C百科ents. I only found how add click event on one widget layout element (with setOnClickPendingIntent), and how send text to widget element TextView.

But it's unclear how handle click events for sub-elements, or how get click coordinates(or item) where was click event. I saw widget "Agenda widget" - and it work fine with clicking on different calendar rows.

I will be very much appreciated for help.


But it's unclear how handle click events for sub-elemets

Use setOnClickPendingIntent().

or how get click coordinates(or item) where was click event

Use different Intents inside of the PendingIntents passed to setOnClickPendingIntent(). By "different", you need something other than an extra to be different, such as a distinct action string.

0

精彩评论

暂无评论...
验证码 换一张
取 消