gpt4 book ai didi

android - 是否可以在其他应用程序中充气 RemoteViews?

转载 作者:行者123 更新时间:2023-12-04 17:53:41 27 4
gpt4 key购买 nike

我正在开发两个 android 应用程序,一个是 baseApp,另一个是 pluginApp。目的是在安装相应插件时扩展 baseApp 的功能。 pluginApp 将包含 XML 布局文件,其中包含我需要在 baseApp 中显示的“new_layouts”。有没有办法通过进程间通信或类似的方法将 new_layout 从 pluginApp 传递给 baseApp?

我尝试了以下方法但没有运气
我将 pluginApp 中的布局文件包装为“RemoteViews”对象并将其传递给 baseApp,但是当我将它膨胀到 baseApp 中时,我收到一条错误消息

android.view.InflateException: Binary XML file line #9: Class not allowed to be inflated android.widget.EditText

注意:“new_layout”在其他元素中包含一个 EditText,EditText 是第一个子元素。

我以前从未使用过 RemoteViews,也不了解它们的用途。

请指导我
1. 是否可以从一个应用程序中使用 View 到另一个应用程序?
2. RemoteViews 可以用于此目的吗?如果是,那怎么办?
3. 为什么我会收到错误,这表明什么?

最佳答案

  1. whether Using view from one app into other app is possible?


不是直接的。

  1. Can RemoteViews be used for this purpose?


是的。

If yes then how?



大概是通过使用您已经拥有的代码。 This pair of sample projects演示了这个过程。

  1. Why am I getting the error


因为 EditText不是 the few widgets supported by RemoteViews 之一.

what does that indicate?



它表明您有三个选择:
  • 限制自己使用 RemoteViews 支持的小部件
  • 不要尝试在应用程序之间共享 UI
  • 实现你自己的RemoteViews类系统

  • 最后,一个 RemoteViews只是一个数据结构,描述了如何构建 UI 以及如何发送回非常粗粒度的事件(例如,点击,通过 PendingIntent )。除了时间和专业知识,没有什么能阻止您创建自己的 Parcelable描述如何构建比 RemoteViews 更丰富的 UI 的数据结构支持。

    关于android - 是否可以在其他应用程序中充气 RemoteViews?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42235358/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com