Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, I have solved the problem myself, through a process of iteration! Others might find this useful.</p> <p>Just create an empty PreferenceScreen in the xml:</p> <pre><code> &lt;PreferenceScreen android:title="Show filters for category" android:summary="Click to choose subjects to delete" android:key="filterShow"&gt; &lt;/PreferenceScreen&gt; </code></pre> <p>Then in the code there is no need for the onClick listener - the contents of the screen are created in the onCreate function. Actually, since the contents of the screen need to change when the choice made in the Category list preference (see original code) changes, this needs to go in a separate function which is called both from onCreate and onSharedPreferenceChanged:</p> <pre><code>public static final String KEY_FILTER_SHOW = "filterShow"; ... private PreferenceScreen mFilterShow; ... // In onCreate: // Get a reference to the PreferenceScreen mFilterShow = (PreferenceScreen)getPreferenceScreen().findPreference(KEY_FILTER_SHOW); // Now the code to create the contents of the screen mFilterShow.removeAll(); CheckBoxPreference cb1 = new CheckBoxPreference(this); cb1.setTitle("This is cb1"); cb1.setKey("cb1_key"); cb1.setDefaultValue(true); mFilterShow.addPreference(cb1); </code></pre> <p>The above is just "proof of concept". It works exactly as you would expect. In my final version, I will create an array of CheckBoxPreferences with 'new' initially, then re-use them (changing title and default) when setting up the contents of the screen for each Category choice as it changes. The number of check boxes required may be different for each category - I will create an array for the maximum number required, then add as many as I need in each case.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload