PreferenceFragment - Difference between getPreferenceManager() and getPreferenceScreen()?

后端 未结 3 1201
情歌与酒
情歌与酒 2020-12-30 19:44

I\'ve implemented my own PreferenceFragment subclass (detailed here), and want to listen for preference changes within it. PreferenceFragment provides you with two ways of d

3条回答
  •  伪装坚强ぢ
    2020-12-30 19:47

    PreferenceScreen see domentation here

    PreferenceScreen class can appear in two places:

    • When a PreferenceActivity points to this, it is used as the root and is not shown (only the contained preferences are shown).
    • When it appears inside another preference hierarchy, it is shown and serves as the gateway to another screen of preferences (either by showing another screen of preferences as a Dialog or via a startActivity(android.content.Intent) from the getIntent()). The children of this PreferenceScreen are NOT shown in the screen that this PreferenceScreen is shown in. Instead, a separate screen will be shown when this preference is clicked.

    PreferenceManager see documentation here:

    Difference :

    getPreferenceManager () returns the current preference manager associated with the fragment.

    getPreferenceScreen () returns the root PreferenceScreen i.e. root preference screen used in the fragment from preference xml file(preferences.xml).

提交回复
热议问题