How to set PreferenceScreen into other layout in android
<p>I want use <code>PreferenceScreen</code> in my application, and create XML layout for this activity in <strong>res/xml/setting_preference.xml</strong>. but this XML layout is very simple, i want use this layout in another layout.<br>
For example : i want use <strong>setting_preference.xml</strong> into <strong>setting_activity.xml</strong> , setting_activity.xml path is <strong>res/layout/setting_activity.xml</strong>.</p>

<p>How can i it?<br>
<strong>setting_preference XML code:</strong> </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;PreferenceCategory
        android:key="setting_title_title_category"
        android:title="Title options"&gt;

    &lt;CheckBoxPreference
        android:id="@+id/setting_title_show_id"
        android:key="setting_title_show"
        android:title="Show Main Title"
        android:summary="Show/hide MainPage title"
        android:checked="true"/&gt;

    &lt;EditTextPreference
        android:key="setting_title_text"
        android:title="Set Main Title"
        android:summary="Change MainPage title"
        android:dialogTitle="Change Title"
        android:dialogMessage="Change title please..."/&gt;

    &lt;/PreferenceCategory&gt;

    &lt;PreferenceCategory
        android:key="setting_title_font_category"
        android:title="Font options"&gt;

        &lt;ListPreference
            android:key="setting_title_font_color"
            android:title="Title font colors"
            android:summary="Change title font colors"
            android:entries="@array/colors"
            android:entryValues="@array/colors"
            android:dialogTitle="Change font color" /&gt;

    &lt;/PreferenceCategory&gt;

    &lt;RingtonePreference
        android:title="tes"/&gt;

&lt;/PreferenceScreen&gt;
</code></pre>

<p><strong>setting_activity XML code:</strong> </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.tellfa.nikandroid.mytestdbproject.SettingPage"&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p><strong>Setting Page code:</strong></p>

<pre><code>public class SettingPage extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if (key.equals("setting_title_font_color")) {
            // get preference by key
            Preference pref = findPreference(key);
            // do your stuff here
        }

        if (key.equals("setting_title_show")){

            Preference pref = findPreference(key);
        }
    }

    public static class MyPreferenceFragment extends PreferenceFragment {
        @Override
        public void onCreate(final Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.xml.setting_prefrences);
        }
    }
}
</code></pre>