Java move <Preference> from one PreferenceScreen to another?
<p>I'm trying to do something similar to iOS editable UITableView. I have a list of "added items" if the user clicks on "Add new item" he is taken to a PreferenceScreen with multiple <code>&lt;Preference&gt;</code> elements, onclick I remove them from this screen and add it to the "Added list" (actually a <code>&lt;PreferenceCategory&gt;</code>), this is similar to iOS editable lists.</p>

<p><img src="http://i.stack.imgur.com/7NNiD.png" alt="Click &quot;Add App&quot;, click on app to add to PreferenceCategory"></p>

<p>This is my xml:</p>

<pre><code>&lt;PreferenceScreen android:title="ALL APPS" android:key="app_list"&gt;  
&lt;/PreferenceScreen&gt;
&lt;PreferenceCategory android:title="ADDED APPS" android:key="my_apps_list"&gt;
&lt;/PreferenceCategory&gt;
</code></pre>

<p>I have tried uncountable times and I cannot get it to work. My recents attemp produce a very strange bug in which the preference is added but it's never removed from the prefernece screen. </p>

<p>How can I get it done?</p>

<hr>

<p>This is what I am trying right now, addPreference() is called when a preference is clicked:</p>

<pre><code>public void addPreference(Preference pref) {
    PreferenceScreen fullList = (PreferenceScreen) findPreference("app_list");
    PreferenceCategory addedList = (PreferenceCategory) findPreference("my_apps_list");
    addedList.addPreference(pref);
    fullList.removePreference(pref);
}
</code></pre>

<p>For some reason this works only one time, afterwards it moves the preference to the <code>&lt;PreferenceCategory&gt;</code> but it doesn't remove it from the <code>&lt;PreferenceScreen&gt;</code>.</p>
