简体   繁体   English

删除多列表首选项摘要上的数组标签

[英]Removing array tags on multilistpreference summary

I have a MultiSelectListPreference() set up. 我有一个MultiSelectListPreference()设置。 My issue isn't displaying the checked value as summary but removing tags of the array when a value is checked. 我的问题不是将检查的值显示为摘要,而是在检查值时删除数组的标签。

Summary of the preference are like this using the below code: 首选项摘要使用以下代码是这样的:

[Adam, Atom, Berry]

But my desired result should be like this when the correct entry is checked as summary: 但是,当正确的条目作为摘要检查时,我期望的结果应该是这样的:

Adam, Atom, Berry

Here is what I have so far that gives me the array tags "[ ]" 到目前为止,这是给我数组标记“ []”的东西

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
 Set<String> selections = preferences.getStringSet("rssfeeds", null);
 String[] selected= selections.toArray(new String[] {});
ssid.getSummary(selected.toString());

Any pointers achieving this?? 任何实现这一目标的指针?

For those that will encounter this in the future, I solved this by looping through the selections then using a StringBuilder() to store each checked box input from the user. 对于将来会遇到此问题的用户,我通过遍历选择内容然后使用StringBuilder()存储用户的每个复选框输入来解决此问题。 I however removed the array tags by just doing replace(old char, new char) where the old char is the tag and the new char is just an empty space "". 但是,我只是通过执行replace(old char, new char)删除了数组标签,其中old char是标签,而new char只是一个空白“”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM