gpt4 book ai didi

android - 从 MultiSelectlList [android] 中获取选定的条目

转载 作者:行者123 更新时间:2023-11-29 21:07:58 24 4
gpt4 key购买 nike

我想从 MultiSelectList 中获取选定的条目(不是 entryValue)。例如,如果选择值 1,我想得到“546544654”。现在我得到了值(value)观。你能帮帮我吗?

MultiSelectListPreference list = (MultiSelectListPreference) findPreference("multiselectlist");

CharSequence[] entries = { "546544654", "12312", "98987","4342423","432423432" };
CharSequence[] entryValues = { "1", "2", "3","4","5" };

list.setEntries(entries); // entries type is String[]
list.setEntryValues(entryValues); // entryValues type is String[]
Set<String> selections = sharedPrefs.getStringSet("multiselectlist", null);

for (String str: selections){
Log.d("salida", str);
}

最佳答案

你可以通过它的位置找到它,当点击 ListView 时

public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

String val =(String) parent.getItemAtPosition(position);
System.out.println("Value is "+val);
}

关于android - 从 MultiSelectlList [android] 中获取选定的条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23904384/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com