Question: I have a PreferenceActivity that loads two Fragments via the xml file for the headers.

I don't seem to be able to set a tag or an ID. or a tag for the fragments in the header xml (that is loaded using loadHeaderFromResource();

Since I don't instantiate it myself I have no ID. or reference to get hold of it.

What do I do?

Answer: 
The [theme system](http://api.drupal.org/api/drupal/modules--system--theme.api.php/group/themeable/7) is the drupal way to do that.

First check if there isn't already a theme function that you can use, there are many that allow to output data as table, lists, images and much more.

If there is not, you need to...

1. Declare a new theme function with [hook\_theme()](http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/7). Prefix it with your module, something like `yourmodule_something`.
2. Create a theme function (or a template), a theme function must be prefixed theme\_, so something like `function theme_yourmodule_something()`.
3. Make sure to clear all caches so that Drupal knows about your theme function.
4. Call the theme function with [theme()](http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/7): `theme('yourmodule_something', $argument1, $argument2)`:

More details can be found on the linked documentation pages.
[hook\_theme](http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/7) is first used to define templates and functions for themed output.

Then, use those templates or theme functions to output any markup, e.g, to call `theme_my_content` or my-content.tpl.php with a couple of parameters, you can call:

`theme('my_content', $param1, $param2);`