简体   繁体   English

如何在AndroidManifest.xml中参数化Activity

[英]How do I parameterize an Activity from within AndroidManifest.xml

I have a CustomListActivity which I wish to expose two facets of the same data. 我有一个CustomListActivity ,我希望公开同一数据的两个方面。

For example: I have a list of cars, and would like to list the set of colors, and the set of models. 例如:我有一个汽车列表,想列出颜色集和模型集。 These would be filtered on mimetype from my ContentProvider : 这些将根据我的ContentProvider mimetype进行过滤:

org.acme.cars.cursor.dir/colors org.acme.cars.cursor.dir/models org.acme.cars.cursor.dir /颜色org.acme.cars.cursor.dir /模型

My CustomListActivity is quite involved, but general enough to be re-used, but: 我的CustomListActivity涉及很多,但是足够通用,可以重复使用,但是:

  • the user should be able to swap between the two lists from a menu/button bar 用户应该能够从菜单/按钮栏中在两个列表之间交换
  • the list is MAIN LAUNCHER intent. 该列表是MAIN LAUNCHER的意图。
  • the user's choice of facet (model or color) should be remembered 记住用户选择的构面(模型或颜色)
  • we should be able to call these activities via mimetype. 我们应该能够通过mimetype调用这些活动。

So, my question is: 所以,我的问题是:

Can I declare two activities in the AndroidManifest.xml, each one with the same class, parameterizing it, or do I need to use some switch from within the class? 我可以在AndroidManifest.xml中声明两个活动,每个活动具有相同的类,对其进行参数化吗?还是需要从该类内部使用某些开关?

为什么不将其保留为单个活动,将布局保留在单独的XML文件中,并使用setContentView在它们之间进行切换?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM