For example: i have three checkboxes in my preference screen and there is 3 different listpreference(A,B,C)
depended on each checkbox. i want to make the user select only one checkbox at a time. How do i achieve this?
There is no radio button in preference screen
I can not use Listpreference , if i can use it
ListPreference
android:key="livewallpaper_testpattern"
android:title="@string/livewallpaper_settings_title"
android:summary="@string/livewallpaper_settings_summary"
android:entries="@array/livewallpaper_testpattern_names"
android:entryValues="@array/livewallpaper_testpattern_prefix"
Array of this Listprefrence is "blue"," red", "white"
if it is blue ListPreference A depends on blue
if it is red ListPreference B depends on red
if it is white ListPreference C depends on white
How can i do this?
i searched 3-4 pages in google and here almost everything about these but i could not find any answer.
Best Regards,
Thanks in advance..
You can override onSharedPreferenceChanged
in your PreferenceActivity
class and enable/disable appropriated Preferences programmatically:
public class MyPreferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
...
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals("livewallpaper_testpattern")) {
if (/* check if livewallpaper_testpattern equals to blue */) {
findPreference("ListPreferenceKey_A").setEnabled(true);
findPreference("ListPreferenceKey_B").setEnabled(false);
findPreference("ListPreferenceKey_C").setEnabled(false);
} else if (/* check if livewallpaper_testpattern equals to red */) {
// enable B, disable A & C
} else if (/* check id livewallpaper_testpattern equals to white */) {
// enable C, disable A & B
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With