在家庭之外重用 WidgetProvider?
我需要我的小部件在应用程序的另一部分中提供的相同功能。在列表活动内。如何在自定义视图中重用我的小部件?我想将小部件放入视图中?这怎么能做到呢?构建自定义主机。我的意思是,我认为我无论如何都需要将我构建的任何内容作为广播接收器,那么我如何重新使用 Widget 提供程序谢谢
I need the same functionality that my widget provides in another part of my application. Inside a list activity. How could I reuse my widget in a custom view? I would like to put the Widget unto a View? How can this be done? Building a custom host. I mean I think I would need for whatever I build to be a broadcast receiver anyway, so how can I resuse the Widget provider Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于本答案的目的,我假设您指的是“应用程序小部件”,其中您说“小部件”。小部件(
android.view.View
的子类)和应用程序小部件之间存在很大差异。一般来说,你不会。您可以将常见的业务逻辑隔离到 AppWidgetProvider 和 ListActivity 都使用的某个帮助程序类中。
那是不可能的,抱歉。
你所以不想走那条路。构建
AppWidgetHost
应保留用于主屏幕或您希望托管第三方应用小部件的其他位置。请重构您的业务逻辑。ListActivity
不会使用AppWidgetProvider
。请重构您的业务逻辑。For the purposes of this answer, I assume you mean "app widget" where you say "widget". There is a big difference between a widget (subclass of
android.view.View
) and an app widget.Generally, you don't. You isolate common business logic into some helper class that both your AppWidgetProvider and your ListActivity use.
That is not possible, sorry.
You so don't want to go down that path. Building an
AppWidgetHost
should be reserved for home screens or other places where you are looking to host app widgets from third parties. Please, just refactor your business logic.A
ListActivity
would not use anAppWidgetProvider
. Please, just refactor your business logic.