ListPreference's summary text is not updated automatically whenever there is change in selection

前端 未结 3 1943
盖世英雄少女心
盖世英雄少女心 2021-02-05 12:33

Although it is being documented, by using \"%s\", I can display selected value as summary, it doesn\'t work as expected.

http://developer.android.com/refere

3条回答
  •  天命终不由人
    2021-02-05 13:13

    IMHO it is a bug. The onClickListener() defined in ListPreference.java#builder.setSingleChoiceItems() does not call notifyChanged()

    I happen to be coding my own ListPreference based on that code, and ran across the same problem as the OP, I added notifyChanged():

                ...
                dialog.dismiss();
                notifyChanged(); // <<<<<<<<<<
            }
    });
    

    and now the preference summary is updated as soon as I choose it. It is not dependent on the Android version, ListPreference has been coded like this since ever.

提交回复
热议问题