title: Android: launch a custom Preference from a PreferenceActivity
body: <p>I would like to be able launch a 2nd Preference screen from my PreferenceActivity.  And in the 2nd Preference screen I'd like to use a predefined layout from xml.  So, I have two questions:</p>
  
  <p>How do I use an xml layout as the layout view of a Preference?
  How do I add this custom preference to a PreferenceActivity such that launched when tapped?</p>
  
  <p>Thank you</p>
  
  <p>*EDIT in response to alibi</p>
  
  <p>I am trying to launch an activity from a preference screen, by declaring the activity to be launched in xml.  This causes this exception:</p>
  
  <pre><code> 04-01 19:04:37.962: ERROR/AndroidRuntime(8061): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.me/CustomPrefScreen}; have you declared this activity in your AndroidManifest.xml?
  </code></pre>
  
  <p>*Another update.  However, if I replace PrefrenceScreen in settings.xml with some extension of Preference, which overrides onClick() to launch CustomPrefScreen, then everything works fine.</p>
  
  <p>Main preferences activity:</p>
  
  <pre><code>public class MyPreferences extends PreferenceActivity 
  {
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.settings);
      }
  }
  </code></pre>
  
  <p>settings.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;PreferenceScreen  
          android:summary="my summary" 
          android:title="my title"&gt;
          &lt;intent android:action="android.intent.action.MAIN"
                      android:targetPackage="com.me"
                      android:targetClass="CustomPrefScreen"/&gt;
      &lt;/PreferenceScreen&gt;
  
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>mainfest file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.me"
      android:versionCode="1"
      android:versionName="1.0"&gt;
      &lt;application 
          android:icon="@drawable/icon" 
          android:label="@string/app_name" 
          android:theme="@style/Theme.NoBackground"&gt;
          &lt;activity 
              android:name=".MyApp"
              android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                   &lt;action android:name="android.intent.action.MAIN" /&gt;
                   &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
               &lt;/intent-filter&gt;
               &lt;/activity&gt;
          &lt;activity 
              android:name=".CustomPrefScreen"
              android:label="@string/app_name"&gt;
          &lt;/activity&gt;
          &lt;activity 
              android:name=".MyPreferences"
              android:label="@string/app_name"&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
      &lt;uses-sdk android:minSdkVersion="4" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;/manifest&gt; 
  </code></pre>