Android - 使用没有 list 条目的 Activity

标签 android android-layout android-manifest

我一直在从事一系列实用 Activity 。目标是用户可以简单地重用源代码,而不需要任何布局 xml 文件。因此,所有布局都是以编程方式创建的。没有对任何布局 xml 文件的引用。

我遇到的唯一问题是用户被迫在 list 文件中输入 Activity 。

我想知道是否有办法让用户绕过这一步。也许用户可以在我的代码中调用一些 Init() 方法,以编程方式将 Activity 添加到“ list ”对象。必须有一些 list 对象的概念,因为 Android 在创建新 Activity 时会查找它。

预先感谢您的帮助。

最佳答案

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.

这似乎不是什么好事。现在,您正在阻止您的重用者轻松修改内容、调整您尚未支持的不同设备特性等。Android 库项目允许您创建包含布局文件和其他资源的可重用组件。

I am wondering if there is a way to bypass this step by the user.

不,抱歉,那是不可能的。

最终,我认为 Android 库项目将支持合并 list 以帮助解决这个问题。

关于Android - 使用没有 list 条目的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7654922/

相关文章:

android - 从服务启动同一个 Activity 的多个实例

java - 为什么这段 Java 代码有效?编译器不会提示关闭

android - 防止按钮根据 TextView 中的文本移动

java - 如何在 Android 中使用字符串计算数学表达式?

安卓 list : Why sometimes ".<classname>" instead of just "<classname>"?

android - 如何在 Android Q 中请求外部文件访问权限?

android - Android 操作栏的最佳实践

java - 使用手机登录 Firebase 返回空指针

Android 从 XML 字符串资源动态创建字符串数组,没有 XML 字符串数组

android - 如何膨胀本身包含线性布局的布局?