我正在尝试为每个数组索引值放置一个 IF 语句,该值来自 MultiSelectList 首选项。但我在执行此操作时遇到问题,这是我的代码,请帮助我。
public void displaySelectedDoa(View view) {
mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> selectionsDoa = mySharedPreferences.getStringSet("selectedDoaKey", null);
String[] selectedDoa = selectionsDoa.toArray(new String[]{});
if (selectedDoa == "0") { // if index number = 0
//do something at here
}
if (selectedDoa == "1") { // if index nuber = 1
//do here
}
}
这是我的偏好片段中的 MultiSelectList
<MultiSelectListPreference
android:title="Select Doa"
android:summary="select your doa"
android:key="selectedDoaKey"
android:entries="@array/select_doa"
android:entryValues="@array/select_doa_value"/>