Android - 使用没有清单条目的活动
我一直在从事一系列实用活动。目标是用户可以简单地重用源代码,并且不需要任何布局 xml 文件。因此,所有布局都是以编程方式创建的。没有对任何布局 xml 文件的引用。
我遇到的唯一问题是用户被迫在清单文件中输入活动。
我想知道用户是否有办法绕过这一步。也许用户可以在我的代码中调用某些 Init() 方法,该方法将以编程方式将活动添加到“清单”对象。必须有一些清单对象的概念,因为 Android 在创建新活动时会查找它。
预先感谢您的帮助。
I have been working on a bunch of utility activities. The goal is that the user simply can reuse the source code and there is no need for any layout xml files. Hence, all the layouts are created programmatically. There is no reference to any layout xml file.
The only problem I am running into is that the user is forced to enter the activities in the manifest file.
I am wondering if there is a way to bypass this step by the user. Perhaps the user can call some Init() method in my code that will programmatically add activities to the "manifest" object. There must be some notion of manifest object as Android is looking it up when a new activity is created.
Thank you in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎不是一件好事。现在,您正在阻止重用者轻松修改内容、调整您尚不支持的不同设备特征等。Android 库项目允许您创建包含布局文件和其他资源的可重用组件。
不,抱歉,这是不可能的。
最终,我认为 Android 库项目将支持清单合并来帮助解决这个问题。
This hardly seems like a good thing. Now you are preventing your reusers from readily modifying matters, to tweak for different device characteristics that you are not yet supporting, etc. Android library projects allow you to create reusable components that contain layout files and other resources.
No, sorry, that is impossible.
Eventually, I think Android library projects will support merging of manifests to help deal with this.